You are on page 1of 2

8/26/2015

Regularexpressions1.Specialcharacters

Regularexpressions1.Specialcharacters
Thefollowingcharactersarethemetacharactersthatgivespecialmeaningtotheregularexpressionsearchsyntax:
\thebackslashescapecharacter.
Thebackslashgivesspecialmeaningtothecharacterfollowingit.Forexample,thecombination"\n"standsforthenewline,oneof
thecontrolcharacters.Thecombination"\w"standsfora"word"character,oneoftheconvenienceescapesequenceswhile"\1"isone
ofthesubstitutionspecialcharacters.
Example:Theregex"aa\n"triestomatchtwoconsecutive"a"sattheendofaline,inclusivethenewlinecharacteritself.
Example:"a\+"matches"a+"andnotaseriesofoneor"a"s.
^thecaretisthestartoflineanchororthenegatesymbol.
Example:"^a"matches"a"atthestartofaline.
Example:"[^09]"matchesanynondigit.
$thedollaristheendoflineanchor.
Example:"b$"matchesa"b"attheendofaline.
Example:"^b$"matchestheemptyline.
{}theopenandclosecurlybracketareusedasrangequantifiers.
Example:"a{2,3}"matches"aa"or"aaa".
[]theopenandclosesquarebracketdefineacharacterclasstomatchasinglecharacter.
The"^"asthefirstcharacterfollowingthe"["negatesandthematchisforthecharactersnotlisted.The""denotesarangeof
characters.Insidea"[]"characterclassconstructionmostspecialcharactersareinterpretedasordinarycharacters.
Example:"[df]"isthesameas"[def]"andmatches"d","e"or"f".
Example:"[az]"matchesanylowercasecharactersinthealfabet.
Example:"[^09]"matchesanycharacterthatisnotadigit.
Example:Asearchfor"[][()?<>.*?]"inthestring"[]()?<>.*?"followedbyareplacestring"r"hastheresult"rrrrrrrrrrrrr".Herethe
searchstringisonecharacterclassandallthemetacharactersareinterpretedasordinarycharacterswithouttheneedtoescapethem.
()theopenandcloseparenthesisareusedforgroupingcharacters(orotherregex).
Thegroupscanbereferencedinboththesearchandthesubstitutionphase.Therealsoexistsomespecialconstructswithparenthesis.
Example:"(ab)\1"matches"abab".
.thedotmatchesanycharacterexceptthenewline.
Example:".a"matchestwoconsecutivecharacterswherethelastoneis"a".
Example:".*\.txt$"matchesallstringsthatendin".txt".
*thestaristhematchzeroormorequantifier.
Example:"^.*$"matchesanentireline.
+theplusisthematchoneormorequantifier.
http://www.fon.hum.uva.nl/praat/manual/Regular_expressions_1__Special_characters.html

1/2

8/26/2015

Regularexpressions1.Specialcharacters

?thequestionmarkisthematchzerooronequantifier.Thequestionmarkisalsousedinspecialconstructswithparenthesisandin
changingmatchbehaviour.
|theverticalpipeseparatesaseriesofalternatives.
Example:"(a|b|c)a"matches"aa"or"ba"or"ca".
<>thesmallerandgreatersignsareanchorsthatspecifyaleftorrightwordboundary.
theminusindicatesarangeinacharacterclass(whenitisnotatthefirstpositionafterthe"["openingbracketorthelastpositionbefore
the"]"closingbracket.
Example:"[AZ]"matchesanyuppercasecharacter.
Example:"[AZ]"or"[AZ]"matchanyuppercasecharacteror"".
&theandisthe"substitutecompletematch"symbol.

Linkstothispage
Regularexpressions
djmw,July18,2001

http://www.fon.hum.uva.nl/praat/manual/Regular_expressions_1__Special_characters.html

2/2

You might also like