10-3 ?用式相???

gLFe`СAڷQUPdzAѨ쥿W¤OOLApAoW\ANnݵ{]p̪gM\OFC UzX`Ψ쪺WAKUPǯiֳtMΡC

PqΦkiCpUG

PqΦk\
re.exec(string)qr string ŦXqΦ re lrAåHr}CǦ^
re.test(string)Hr string qΦ reAöǦ^ﵲG]true N令\Afalse N異ѡ^
string.search(re)qΦ re bYӦr string X{m
string.match(re)qr string ŦXqΦ re lrAåHr}CǦ^A\M re.exec(string) ۦP
string.replace(re, newStr)Nr string ŦXqΦ re AN newStr

bUC椤Aڭ̨ϥδX²檺dҨӹqΦΰ㪺G

νd藍ߤr
/a/tr "a" rAҦp "ab", "bac", "cba""xyz"
/a./tr "a" HΨ@ӦrrAҦp "ab", "bac"]Yn.AШϥ \.^"a", "ba"
/^xy/H "xy" }lrAҦp "xyz", "xyab"]Yn ^AШϥ \^^"axy", "bxy"
/xy$/H "xy" rAҦp "axy", "abxy"H "xy" rAҦp "axy", "abxy" ]Yn $AШϥ \$^"xya", "xyb"
/[13579]/]t "1" "3" "5" "7" "9" rAҦpG"a3b", "1xy""y2k"
/[0-9]/tƦrrtƦrr
/[a-z0-9]/tƦrΤpgrrtƦrΤpgrr
/[a-zA-Z0-9]/tƦrΦrrtƦrΦrr
/b[aeiou]t/"bat", "bet", "bit", "bot", "but""bxt", "bzt"
/[^0-9]/tƦrr]Yn ^AШϥ \^^tƦrr
/[^aeiouAEIOU]/tr]Yn ^AШϥ \^^tr
/[^\^]/t "^" rAҦp "xyz", "abc""xy^", "a^bc"

Ъ`NbWA"^" b׽uAN@Ӧrꪺ}lmA] /^xy/ NH "xy" }lrC PzA"$" b׽uAN@ӦrꪺmA] /xy$/ NH "xy" rC OpGN "^" bӤAANNu_wvA] [^aeiouAEIOU] NtrC

t~AYnױSrSNqANnbre[W "\"AҦpW̫@CA"^" bA̭ONu_wvA]YnbA̭ "^"ANnϥ "\^"AҥHut "^" rvqΦNO "[^\^]"C

H RegExp(pattern, flag) 覡ӫإ߳qΦɡAY pattern ]tHϱ׽u}YSr]Ҧp \dB\wB\s ^ɡAڭ̥A[W@Ӥϱ׽uӫOdSNqCҦpG

re = /\d+\s\w+/g H RegExp DĪܪkG re = new RegExp("\\d+\\s\\w+", "g");

dzqΦ|`QΨA]wQwqSwrAH²ƾqΦAoǦriCpUG

qΪܪkSwrĪqΪܪk
\dƦr[0-9]
\DDƦr[^0-9]
\wƦrBrBu[a-zA-Z0-9_]
\WD \w[^a-zA-Z0-9_]
\sťզr[ \r\t\n\f]
\SDťզr[^ \r\t\n\f]

~Aڭ̥iwqrƦơApUG

qΪܪk
/a?/sΤ@ a]Yn? rAШϥ \?^
/a+/@Φh a]Yn+ rAШϥ \+^
/a*/sΦh a]Yn* rAШϥ \*^
/a{4}/| a
/a{5,10}/ܤQ a
/a{5,}/ܤ֤ a
/a{,3}/ܦhT a
/a.{5}b/a M bӡ]D^r

۫HU{bwgiH|qΪܦ¤OFI

HUAqΦAi㪺CPG

r ²d
\ ׶}Sr /A\*/ iΩ "A*"A䤤 * O@ӯSrA׶}SNqAҥH[W "\"
^ JC_lm /^A/ i "Abcd" "A"Ai "aAb"
$ JCm /A$/ i "bcdA" "A"Ai "aAb"
* e@ӦrsΧh /bo*/ i "Good boook" "booo"Ai "Good bk" "b"
+ e@Ӧr@ΧhAĩ {1,} /a+/ i "caaandy" "aaa"Ai "cndy"
? e@ӦrsΤ@ /e?l/ i "angel" "el"A]iH "angle" "l"
. @Ӧr]Ÿ^ /.n/ i "nay, an apple is on the tree" "an" M "on"Ai "nay"
(x) x ñNŦXsJ@ܼ /(a*) and (b*)/ i "aaa and bb" "aaa" M "bb"AñNoӤo쪺r]wܼ RegExp.$1 M RegExp.$2C
x|y x y /a+|b+/g i "aaa k bb" "aaa" M "bb"
{n} e@Ӧr n An @ӥ /a{3}/ i "lllaaalaa" 䤤 "aaa"Ai "aa"
{n,} e@Ӧrܤ n An @ӥ /a{3,}/ i "aa aaa aaaa" 䤤 "aaa" "aaaa"Ai "aa"
{n,m} e@Ӧrܤ n Aܦh m AmBn /a{3,4}/ i "aa aaa aaaa aaaaa" 䤤 "aaa" "aaaa"Ai "aa" "aaaaa"
[xyz] 襤A@Ӧr /[ecm]/ i "welcome" "e" "c" "m"
[^xyz] 藍bAX{@Ӧr /[^ecm]/ i "welcome" "w"B"l"B"o"AiXP [xyz] \ۤϡC]PɽЦPǤ]`N /^/ P [^] \઺PC^
[\b] hr]Backspace character^ iH@ backspace A]Ъ`N [\b] P \b tO
\b ^rɡAҦpŮ Ҧp /\bn\w/ iH "noonday" 'no' ;
/\wy\b/ i "possibly yesterday." 'ly'
\B Du^rɡv Ҧp, /\w\Bn/ iH "noonday" 'on' ,
t~ /y\B\w/ iH "possibly yesterday." 'ye'
\cX ﱱr]Control character^A䤤 X O@ӱr /\cM/ iH @Ӧrꤤ control-M
\d @ӼƦrAĩ [0-9] /[\d]/ i "0" "9" @Ʀr lprNi
\D @ӫDƦrAĩ [^0-9] /[\D]/ i "w" "a"... ip "7" "1" Ʀr
\f form-feed YObro "" 欰 hiH令\
\n ﴫŸ YObro "" 欰 hiH令\
\r carriage return  
\s @Ӫťզr]White space character^Aĩ [ \f\n\r\t\v] /\s\w*/ i "A b" "b"
\S @ӫDťզrAĩ [^ \f\n\r\t\v] /\S/\w* i "A b" "A"
\t wr]Tab^  
\v 﫫wr]Vertical tab^  
\w Ʀrrr]Alphanumerical characters^Ωur]"_"^Aĩ [A-Za-z0-9_] /\w/ i ".A _!9" "A"B"_"B"9"C
\W DuƦrrrΩurvAĩ [^A-Za-z0-9_] /\W/ i ".A _!9" "."B" "B"!"Ai\P /\w/ nۤϡC
\ooctal KiA䤤octalOKiƥ /\oocetal123/ i P Ki쪺ASCII "123" Ҭ۹rȡC
\xhex QiA䤤hexOQiƥ /\xhex38/ i P 16i쪺ASCII "38" Ҭ۹rC


JavaScript {]pPΡGΩΤ