• Like
Js reg正则表达式
Upcoming SlideShare
Loading in...5
×

Js reg正则表达式

  • 362 views
Uploaded on

正则表达式笔记。

正则表达式笔记。

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
362
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. CHAPTER 10Pattern Matching with Regular Expressions 2011-04-11 dale Javascript正则表达式
  • 2. 1. Definition• RegExp objects – var pattern = /s$/; – var pattern = new RegExp(); // use constructor Js Reg Perl Reg
  • 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. Special Character• ^$.*+?=!:|/()[]{}
  • 5. 10.1.2 Character Classes• /[abc]/• /[a-z]/• /[a-zA-Z0-9]/ // Latin alphabet
  • 6. 10.1.3 Repetition(repeat)• /dd/ //匹配2位数字• /dddd/ //匹配4位数字
  • 7. • /(*‘”+)*^‘””+*1/ // ‘你好’ //“hello”
  • 8. 实例var reg = /[a-zA-Z_]{6,9}/g;Var myString="guoguqoo0000_";reg.test(MyString);
  • 9. String类与regular• myString.match(reg)• myString.replace(reg,$n)• myString.search(re) //-1 intIndex• myString.split(reg[,5]) //分割返回前5个
  • 10. • /b^[a-z]w{5,7}b/