Your SlideShare is downloading. ×
0
CHAPTER 10Pattern Matching with Regular Expressions     2011-04-11 dale        Javascript正则表达式
1. Definition• RegExp objects  – var pattern = /s$/;  – var pattern = new RegExp(); // use constructor                  Js...
10.1.1 Literal Characters•   Character Matches字母•   Alphanumeric数字•   Character字符•   0 The NUL character (u0000•   t Tab (...
Special Character• ^$.*+?=!:|/()[]{}
10.1.2 Character Classes• /[abc]/• /[a-z]/• /[a-zA-Z0-9]/ // Latin alphabet
10.1.3 Repetition(repeat)• /dd/ //匹配2位数字• /dddd/ //匹配4位数字
• /(*‘”+)*^‘””+*1/ // ‘你好’   //“hello”
实例var reg = /[a-zA-Z_]{6,9}/g;Var myString="guoguqoo0000_";reg.test(MyString);
String类与regular•   myString.match(reg)•   myString.replace(reg,$n)•   myString.search(re) //-1 intIndex•   myString.split(...
• /b^[a-z]w{5,7}b/
Upcoming SlideShare
Loading in...5
×

Js reg正则表达式

407

Published on

正则表达式笔记。

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
407
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Js reg正则表达式"

  1. 1. CHAPTER 10Pattern Matching with Regular Expressions 2011-04-11 dale Javascript正则表达式
  2. 2. 1. Definition• RegExp objects – var pattern = /s$/; – var pattern = new RegExp(); // use constructor Js Reg Perl Reg
  3. 3. 10.1.1 Literal Characters• Character Matches字母• Alphanumeric数字• Character字符• 0 The NUL character (u0000• t Tab (u0009)• n Newline (u000A)• v Vertical tab (u000B)• f Form feed (u000C) 换页• r• x• u• c
  4. 4. Special Character• ^$.*+?=!:|/()[]{}
  5. 5. 10.1.2 Character Classes• /[abc]/• /[a-z]/• /[a-zA-Z0-9]/ // Latin alphabet
  6. 6. 10.1.3 Repetition(repeat)• /dd/ //匹配2位数字• /dddd/ //匹配4位数字
  7. 7. • /(*‘”+)*^‘””+*1/ // ‘你好’ //“hello”
  8. 8. 实例var reg = /[a-zA-Z_]{6,9}/g;Var myString="guoguqoo0000_";reg.test(MyString);
  9. 9. String类与regular• myString.match(reg)• myString.replace(reg,$n)• myString.search(re) //-1 intIndex• myString.split(reg[,5]) //分割返回前5个
  10. 10. • /b^[a-z]w{5,7}b/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×