RegEx для чайников в картинках

1. Matching a Username

Matching a username

Pattern:

String that matches:

my-us3r_n4m3

String that doesn’t match:

th1s1s-wayt00_l0ngt0beausername (too long)

2. Matching a Password

Matching a password

Pattern:

String that matches:

myp4ssw0rd

String that doesn’t match:

mypa$$w0rd (contains a dollar sign)

3. Matching a Hex Value

Matching a hex valud

Pattern:

String that matches:

#a3c113

String that doesn’t match:

#4d82h4 (contains the letter h)

4. Matching a Slug

Matching a slug

Pattern:

String that matches:

my-title-here

String that doesn’t match:

my_title_here (contains underscores)

5. Matching an Email

Matching an email

Pattern:

String that matches:

john@doe.com

String that doesn’t match:

john@doe.something (TLD is too long)

6. Matching a URL

Matching a url

Pattern:

String that matches:

http://net.tutsplus.com/about

String that doesn’t match:

http://google.com/some/file!.html (contains an exclamation point)

7. Matching an IP Address

Matching an IP address

Pattern:

String that matches:

73.60.124.136 (no, that is not my IP address :P)

String that doesn’t match:

256.60.124.136 (the first group must be «25» and a number between zero and five)

8. Matching an HTML Tag

Matching an HTML tag

Pattern:

String that matches:

Nettuts+

String that doesn’t match:

My image> (attributes can’t contain greater than signs)

©  8 Regular Expressions You Should Know — Tuts+ Code Tutorial.

& http://www.regxlib.com

Реклама