LoginSignup
0
0

More than 5 years have passed since last update.

Regular Expressions (realistic example)

Last updated at Posted at 2016-02-11

Sites for testing / more info:
https://regex101.com/
http://regexone.com/
http://www.cheatography.com/davechild/cheat-sheets/regular-expressions/

Find emails using this :

"^(([a-zA-Z]|[0-9])|([-]|[_]|[.]))+[@](([a-zA-Z0-9])|([-])){2,63}[.](([a-zA-Z0-9]){2,63})+$"
this will get accept valid email formats

Finding home #, mobile #:

"^([0-9]{3,})[-]([0-9]{4})$" this is for home phone numbers like "655-7663" (with the '-' dash sign)
"^0[0-9]{10}$" -this is for finding cellphone numbers (pure numbers only like "09055741020"
"^+63[0-9]{10}$" - this is also for finding cell #s in the format of country code + number like "+639055741020"

Find URLs

^(http(s){0,1}:\/\/){0,1}(www.){0,1}[0-9a-zA-z]{2,}((.[A-z]{2,}){1,})(\/[A-z0-9]+)\/$
this can find complete urls with http(s) , www, or just domain name like, yahoo.com, can also find with trailing /word/ as many times possible
for example website.com/index/profile/2/save is allowed

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0