Regular Expressions
Reference: www.regular-expressions.info, Online tool.
cat|dog
: Alternates,cat
ordog
.\/[^\/]+$
Everything after last/
on line.^.*svn ci -m
Variable prefix ending in "svn ci -m ".^[^{]+\{\{
Find first (not last){{
on each line."last_updated": ".+[^,]$
Find lines with"last_updated": "
and not ending in a comma.- Use curly braces to specify repetition. Examples:
[A-Za-z0-9]{32}
32-character alphanumeric;[1-9][0-9]{2,4}
Number from 100 to 99999. exchange_rate
not followed by a,
:exchange_rate(?!,)
.^((?!affectv).)*$
: Match all lines without stringaffectv
.<!--[^>]*-->
HTML comments.
Special Characters
.
Matches any character.(
This marks the start of a region for tagging a match.)
This marks the end of a tagged region.\n
Where n is 1 through 9 refers to the first through ninth tagged region when searching or replacing. Searching for(Wiki)\1
matchesWikiWiki
. If the search string wasFred([1-9])XXX
and the replace string was *Sam\1YYY
, when applied toFred2XXX
this would generateSam2YYY
.\0
When replacing, the whole matching text.\b
This matches a word boundary.\c
A backslash followed on of the following becomes a character class (both inside and outside sets[]
).d
Decimal digits.D
Any char except decimal digits.s
Whitespace (space,\t
,\n
,\r
,\f
and\v
).S
Any char except whitespace.w
Alphanumeric & underscore.W
Any char except alphanumeric & underscore.
\x
This allows you to use a characterx
that would otherwise have a special meaning. For example,\[
would be interpreted as[
and not as the start of a character set. Use\\
for a literal backslash.[...]
Matches one of the characters in the set. If the first character in the set is^
, it matches the characters NOT in the set. A shorthandS-E
(start dash end) is used to specify a set of charactersS
up toE
, inclusive. The special characters]
and-
have no special meaning if they appear first in the set.-
can also be last in the set. To include both, put]
first:[]A-Z-]
. Examples:[a-z]
Any lowercase alpha;[^]-]
Any char except-
and]
;[a-zA-Z]
Any alpha.^
Matches the start of a line (unless used inside a set, see above).$
Matches the end of a line.*
Matches 0 or more times. For example,Sa*m
matchesSm
,Sam
,Saam
,Saaam
and so on.+
Matches 1 or more times. For example,Sa+m
matchesSam
,Saam
,Saaam
and so on.?
Matches 0 or 1 time(s). For example,Joh?n
matchesJohn
andJon
.