-
Notifications
You must be signed in to change notification settings - Fork 69
Open
Description
- 練習
> let text = "name:ccc age:52 weight:60"
undefined
> let re = /[0-9]+/g
undefined
> re
/[0-9]+/g
> text
"name:ccc age:52 weight:60"
> text.match(re)
[ "52", "60" ]
> let re2 = /[a-z]+/g
undefined
> text.match(re2)
[ "name", "ccc", "age", "weight" ]
> let re3 = /:([0-9a-zA-Z])+/g
undefined
> text.match(re3)
[ ":ccc", ":52", ":60" ]
> let re4 = /:([0-9a-zA-Z])+/
undefined
> text.match(re4)
[ ":ccc", "c" ]
> let re5 = /:([0-9a-zA-Z]+)/
undefined
> let re5 = /:([0-9a-zA-Z]+)/
undefined
> text.match(re5)
[ ":ccc", "ccc" ]
> let re5 = /:\w+)/
Uncaught SyntaxError: Invalid regular expression: /:\w+)/: Unmatched ')'
> let re5 = /:\w+/
undefined
> text.match(re5)
[ ":ccc" ]
> let re6 = /:\d+/
undefined
> let re6 = /:\d+/g
undefined
> text.match(re6)
[ ":52", ":60" ]
> let re7 = /:\D+/g
undefined
> text.match(re7)
[ ":ccc age:" ]
> let text = 'hello world , ccc , your email is ccc@nqu.edu.tw , how are you !'
undefined
> text
"hello world , ccc , your email is ccc@nqu.edu.tw , how are you !"
> let re = /\w+@[\w\.]+/g
undefined
> text.match(re)
[ "ccc@nqu.edu.tw" ]
> let text2 = text + ' abc ccc@q ... '
undefined
> text2
"hello world , ccc , your email is ccc@nqu.edu.tw , how are you ! abc ccc@q ... "
> text.match(re)
[ "ccc@nqu.edu.tw" ]
> text2.match(re)
[ "ccc@nqu.edu.tw", "ccc@q" ]
> let re = /\w+@\w+\.[\w\.]+/g
undefined
> text2.match(re)
[ "ccc@nqu.edu.tw" ]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels