Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

習題 7 -- 正規表達式練習 #27

Open
ccckmit opened this issue May 20, 2022 · 34 comments
Open

習題 7 -- 正規表達式練習 #27

ccckmit opened this issue May 20, 2022 · 34 comments

Comments

@ccckmit
Copy link
Contributor

ccckmit commented May 20, 2022

  1. 練習
> 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" ]
@markerpen92
Copy link

markerpen92 commented May 20, 2022

@LeeYi-user
Copy link

資工一 李易 111010512

> let text = "name: LeeYi, age: 18, job: student;"
undefined

> let re1 = /, |[a-z]*/
undefined
> text.match(re1)
[ "name" ]

> let re2 = /[A-Z][a-z]+[A-Z][a-z]+/
undefined
> text.match(re2)
[ "LeeYi" ]

> let re3 = /age/
undefined
> text.match(re3)
[ "age" ]

> let re4 = /\d+/g
undefined
> text.match(re4)
[ "18" ]

> let re5 = /, |.*\: /g
undefined
> text.match(re5)
[ "name: LeeYi, age: 18, job: " ]

> let re6 = /\: *[a-z]*/g
undefined
> text.match(re6)
[ ": ", ": ", ": student" ]

@weixiang0470
Copy link

黃偉祥 111010550
Homework 7

@123456789203
Copy link

@asd1389271903
Copy link

asd1389271903 commented May 30, 2022

@siyu0927
Copy link

@RogerChen530
Copy link

@weichen11011
Copy link

@jiajianong
Copy link

@Jung217
Copy link

Jung217 commented Jun 11, 2022

111010501 簡志融
Code

@byby9527
Copy link

@weilunh7
Copy link

111010514 黃威綸
https://github.com/weilunh7/wp110b/blob/master/HW7.js

@Ellinaa
Copy link

Ellinaa commented Jun 12, 2022

110910558陳玟卉

@peiyun328
Copy link

111010507 資工一 許珮筠

> let text = "name:peiyun age:19 height:163"
undefined
> let re0 = /[0-9a-zA-z]+/g
undefined
> re0
/[0-9a-zA-z]+/g
> text
"name:peiyun age:19 height:163"
> text.match(re0)
[ "name", "peiyun", "age", "19", "height", "163" ]
> let re1 = /[0-9]+/g
undefined
> text.match(re1)
[ "19", "163" ]
> let re2 = /[a-z]+/g
undefined
> text.match(re2)
[ "name", "peiyun", "age", "height" ]
> let re3 = /[0-9a-z]+/g
undefined
> text.match(re3)
[ "name", "peiyun", "age", "19", "height", "163" ]
> let re4 = /[0-9a-zA-Z]+/
undefined
> text.match(re4)
[ "name" ]
> let re5 = /:[0-9a-z]+/g
undefined
> text.match(re5)
[ ":peiyun", ":19", ":163" ]
> let re6 = /:([0-9a-z])+/
undefined
> text.match(re6)
[ ":peiyun", "n" ]
> let re7 = /:([0-9a-z]+)/
undefined
> text.match(re7)
[ ":peiyun", "peiyun" ]
> let re7 = /:\w+/
undefined
> text.match(re7)
[ ":peiyun" ]
> let re8 = /:\d+/
undefined
> text.match(re8)
[ ":19" ]
> let re8 = /:\d+/g
undefined
> text.match(re8)
[ ":19", ":163" ]
> let re9 = /:\D+/g
undefined
> text.match(re9)
[ ":peiyun age:" ]
> let tex = "Hi, peiyun, how are you? You have 10 missed call."
undefined
> tex
"Hi, peiyun, how are you? You have 10 missed call."
> let re = /\w[0-9A-Z]+/g
undefined
> text.match(re)
[ "19", "163" ]
> let re0 = /[0-9]+/g
undefined
> text.match(re0)
[ "19", "163" ]
> let text =  "Hi, peiyun, how are you? You have 10 missed call.And Mr.Lin had send you an email: lin0421@gmail.com"
undefined
> text
"Hi, peiyun, how are you? You have 10 missed call.And Mr.Lin had send you an email: lin0421@gmail.com"
> let re0 = /:\w+/
undefined
> let re0 = /:\w+@[\w\.]+/g
undefined
> let text2 = "Hi, peiyun, how are you? You have 10 missed call.And Mr.Lin had send you an email: lin0421@gmail.com"
undefined
> text2
"Hi, peiyun, how are you? You have 10 missed call.And Mr.Lin had send you an email: lin0421@gmail.com"
> text2.match(re)
[ "10", "n0421" ]
> let re = /\w+@\w+\.[\w\.]+/g
undefined
> text2.match(re)
[ "lin0421@gmail.com" ]
> let text2 = text + "  abc    ccc@q  ... "
undefined
> text2
"Hi, peiyun, how are you? You have 10 missed call.And Mr.Lin had send you an email: lin0421@gmail.com  abc    ccc@q  ... "
> text2.match(re)
[ "lin0421@gmail.com" ]
> let re1 = /\w+@[\w\.]+/g
undefined
> text2.match(re1)
[ "lin0421@gmail.com", "ccc@q" ]
> text2.match(re)
[ "lin0421@gmail.com" ]

@samue02l
Copy link

@yuzi0521
Copy link

yuzi0521 commented Jun 14, 2022

111010527 顏郁茨

1.practice

> let text="name:yuzi age:18 email:s111010527@student.nqu.edu.tw"
undefined
> let re = /[0-9]+/g
undefined
> re
/[0-9]+/g
> text
"name:yuzi age:18 email:s111010527@student.nqu.edu.tw"
> text.match(re)
[ "18", "111010527" ]
> let re2 = /[a-z]+/g
undefined
> text.match(re2)
[
  "name", "yuzi",
  "age",  "email",
  "s",    "student",
  "nqu",  "edu",
  "tw"
]
> let re3 = /:([0-9a-zA-Z])+/g
undefined
> text.match(re3)
[ ":yuzi", ":18", ":s111010527" ]
>let re4 = /:([0-9a-zA-Z])+/
undefined
> text.match(re4)
[ ":yuzi", "i" ]
>  let re5 = /:([0-9a-zA-Z]+)/
undefined
> text.match(re5)
[ ":yuzi", "yuzi" ]
> let re6 = /:\w+/
undefined
> text.match(re6)
[ ":yuzi" ]
> let re7 = /:\d+/
undefined
> text.match(re7)
[ ":18" ]
> let re8 = /:\d+/g
undefined
> text.match(re8)
[ ":18" ]
> let re9 = /:\D+/g
undefined
> text.match(re9)
[ ":yuzi age:", ":s" ]

2.catch email

>let text2 = "hi, i'm yuzi :) do you like vtuber? if you like you can email me. my email is s111010527@student.nqu.edu.tw"
undefined
> text2
"hi, i'm yuzi :) do you like vtuber? if you like you can email me. my email is s111010527@student.nqu.edu.tw"
> let text2 = text2 + "  abc   gura@cute  ... "
undefined
> text2
"hi, i'm yuzi :) do you like vtuber? if you like you can email me. my email is s111010527@student.nqu.edu.tw  abc   gura@cute  ... "
>let re1 = /\w+@[\w\.]+/g
undefined
> text2.match(re1)
[ "s111010527@student.nqu.edu.tw", "gura@cute" ]
> let re = /\w+@\w+\.[\w\.]+/g
undefined
> text2.match(re)
[ "s111010527@student.nqu.edu.tw" ]

@Tzuan1020
Copy link

111010517 蘇子安
https://github.com/Tzuan1020/wp110b/blob/master/hw7.js

@Chieh0622
Copy link

111010515 林弘杰
code

@KimLinTW
Copy link

@leeeeeeeeeeeeeeeeeeeeeee

111010553 李沃原

@CJI3751
Copy link

CJI3751 commented Jun 15, 2022

@yihsien924
Copy link

@wei-annn
Copy link

110910504趙唯安
https://github.com/wei-annn/wp110b/wiki/hw7.md

@st950344
Copy link

@dallas145
Copy link

@ali1234-56
Copy link

@rossen1020
Copy link

@nelson023
Copy link

@samlin911227
Copy link

111010533 林達城
js

@MitanEXE
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests