Regex symbol list and regex examples - Codexpedia
文章推薦指數: 80 %
Regex symbol list and regex examples ; \b Backslash and b, matches a word boundary. For example, “\bwater” finds “watergun” but not “cleanwater” whereas “water\b ... Codexpedia Codexpedia(current) About Contact Search Regexsymbollistandregexexamples .Period,matchesasinglecharacterofanysinglecharacter,excepttheendofaline.Forexample,thebelowregexmatchesshirt,shortandanycharacterbetweenshandrt. sh.rt ^Carat,matchesatermifthetermappearsatthebeginningofaparagraphoraline.Forexample,thebelowregexmatchesaparagraphoralinestartswithApple. ^Apple ^Caratinsideabracket,forexample,thebelowregexmatchesanycharactersbuta,b,c,d,e. [^a-e] $Dollarsign,matchesatermifthetermappearsattheendofaparagraphoraline.Forexample,thebelowregexmatchesaparagraphoralineendswithbye. bye$ []Squarebrackets,matchesanysinglecharacterfromwithinthebracketedlist.Forexample,thebelowregexmatchesbad,bed,bcd,brd,andbod. b[aecro]d –Hyphen,usedforrepresentingarangeoflettersornumbers,oftenusedinsideasquarebracket.Forexample,thebelowregexmatcheskam,kbm,kcm,k2m,k3m,k4mandk5m. k[a-c2-5]m ()Parentheses,groupsoneormoreregularexpressions.Forexample,thebelowregexmatchescodexpedia.com,codexpedia.net,andcodexpedia.org. codexpedia\.(com|net|org) {n}Curlybracketswith1numberinsideit,matchesexactlyntimesoftheprecedingcharacter.Forexample,thebelowregularexpressionmatches4digitsstring,andonlyfourdigitsstringbecausethereis^atthebeginningand$attheendoftheregex. ^[\d]{4}$ {n,m}Curlybracketswith2numbersinsideit,matchesminimumandmaximumnumberoftimesoftheprecedingcharacter.Forexample,thebelowregularexpressionmatchesgoogle,gooogleandgoooogle. go{2,4}gle {n,},Curlybracketswithanumberandacomma,matchesminimumnumberoftimestheprecedingcharacter.Forexample,thebelowregexmatchesgoogle,gooogle,gooooogle,goooooogle,…. go{2,}gle |Pipe,matcheseithertheregularexpressionprecedingitortheregularexpressionfollowingit.Forexample,thebelowregexmatchesthedateformatofMM/DD/YYYY,MM.DD.YYYYandMM-DD-YYY.ItalsomatchesMM.DD-YYYY,etc. ^(0[1-9]|1[012])[-/.](0[1-9]|[12][0-9]|3[01])[-/.][0-9]{4}$ ?Questionmark,matches1or0characterinfrontofthequestionmark.Forexample,thebelowregularexpressionmatchesappleandapples. apples? *Asterisk,matches0ormorecharactersinfrontoftheasterisk.Forexample,thebelowregularexpressionmatchescl,col,cool,cool,…,coooooooooool,… co*l +Plus,matches1ormorecharactersinfronoftheplus.Forexample,thebelowregularexpressionmatchescol,cool,…,cooooooooooool,… co+l !Exclamation,donotmatchesthenextcharacterorregularexpression.Forexample,thebelowregularexpressionmatchesthethecharacherqifthecharachterafterqisnotadigit,itwillmatchestheqinthosestringsofabdqk,quit,qeig,butnotq2kd,sdkq8d. q(?![0-9]) \Backslash,turnsoffthespecialmeaningofthenextcharacter.Forexample,thebelowregextreatstheperiodasanormalcharacteranditmatchesa.bonly. a\.b \bBackslashandb,matchesawordboundary.Forexample,“\bwater”finds“watergun”butnot“cleanwater”whereas“water\b”finds“cleanwater”butnot“watergun”. \nBackslashandn,representsalinebreak. \tBackslashandt,representsatab. \wBackslashandw,itisequivalentto[a-zA-Z0-9_],matchesalphanumericcharacterorunderscore.Conversely,Capital\Wwillmatchnon-alphnumericcharacterandnotunderscore. \dBackslashandd,matchesdigits0to9,equivalentto[0-9]or[:digit] [:alpha:]or[A-Za-z]representsanalphabeticcharacter. [:digit:]or[0-9]or[\d]representsadigit. [:alnum:]or[A-Za-z0-9]representsanalphanumericcharacter. Thisregexmatchesemailaddresses \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b Thisregexmatcheswebsiteslinksendingwithsitesof.com,.org,.edu,.govand.us https?://(www\.)?[A-Za-z0-9]+\.(com|org|edu|gov|us)/?.* Thisregexmatchessocialsecuritynumbers. ^[0-9]{3}-[0-9]{2}-[0-9]{4}$ SearchwithinCodexpedia CustomSearch Searchtheentireweb CustomSearch RelatedPosts Javaregularexpressionexample Regexsymbollistandregexexamples More ←fileownershipsandfilepermisionsonLinuxandunixlikesystemsinstallingUbuntuonVirtualBox→
延伸文章資訊
- 1Regular Expressions - Pages supplied by users
REGEX BASICS ; Matching simple expressions, Most characters match themselves. The only exceptions...
- 2Regex symbol list and regex examples - Codexpedia
Regex symbol list and regex examples ; \b Backslash and b, matches a word boundary. For example, ...
- 3Regular Expression (Regex) Tutorial
A range expression consists of two characters separated by a hyphen ( - ). It matches any single ...
- 4Regular expressions 1. Special characters
The following characters are the meta characters that give special meaning to the regular express...
- 5正規表達式- JavaScript - MDN Web Docs
在JavaScript 中,正規表達式也是物件,這些模式在RegExp 的exec ... regular expression engine defines a specific set of...