Regular Expressions (2) ---- Common Used Samples

xiaoxiao2021-03-06  61

Regular Expressions (2) ---- Common Used Samples

Description:

All of the following examples are verified under EditPad Pro, if not, may be related to a specific interpretation engine, it is a slight modification. J (I have dizzy ~~)

More examples: http://www.regexlib.com

Email verification ... 2

Simple verification email address ... 2

Standard verification email address ... 2

Digital verification ... 2

Decimal numbers greater than zero ... 2

Any Decimal number ... 2

Belt or noncompetent numbers 0-99999999 ... 3

0-65535 value ... 3

String verification ... 3

HTML and XML cousin ... 3

ISBN format string ... 3

GUID. 4

Credit card number ... 4

Two the same words together ... 4

The word enclosed in double quotes ... 4

Mark ... 5

Verify 16-bit color values ​​in HTML ... 5

Verify HTML code containing JSP events ... 5

Verify a pair of closed XML markers ... 5

Verify all legitimate ON events in HTML ... 5

Find comments in HTML ... 6

Find specific files in HTML (swf.jpg.gif ...) ... 6

Date and time verification ... 6

Date verification ... 6

Date and time verification ... 6

Standard ANSI SQL Date Verification ... 7

Other ... 7

Match font ... 7

Match MD5 Haxi string ... 7

Email verification

Simple verification email address

expression

(/W [-._/w]*/w@/w [-._/w]*/w/./w /2】

description

Simply in line with @ xxx.com.

Rough verification

Match example

[foo@bar.com], [foobar@foobar.com.au]

Mismatch example

[foo @ bar], [$$$@bar.com]

Standard verification email address

expression

^ (([^ <>; () [/] // .;:@ "] (/. [^ <> () [/] /////Ww. @"] ) *) | ". ")) @ ((([az] ([- a-z0-9] * [a-z0-9])?) | (# [0-9] ) | (/ [((( [01] [0-9] {0,2}) | (2 ((([0-4] [0-9]) | (5 [0-5]))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) ([01]? [0-9] {0,2}) | (2 (([0-4] [0-9]) | (5 [0-5])))))))))))))) ) * (([AZ] ([- A-Z0-9])?) | (# [0-9] ) | (/ [((((((([01]? [0 -9] {0, 2}) | (2 (([0-4]) | (5 [0-5])))))))))) /.) {3} (([01]? 0-9] {0,2}) | (2 (([0-4] [0-9]) | (5 [0-5]))))))))) /]) $

description

All email addresses that match RFC 821 (http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc0821.html#page-30)

Match example

Blah @ [10.0.0.1] |||@b.c

Mismatch example

Non @ match @.

Digital verification

Decimal numbers greater than zero

expression

(^ / d * /.? / d * [1-9] / d * $) | (^ [1-9] / d * /. / d * $)

description

Decimal numbers greater than zero

Match example

0.050

5.0000

5000

Mismatch example

0

0.0

.0

Any Decimal number

expression

^ (/ d | -)? (/ d |,) * /.? / d * $

description

match:

Pure number

negative number

Command-divided number

Point segmentation Decimal format

Matching Example 5,000

-5,000

100.044

.2

Mismatch example

ABC

1.3.4

Belt or noncompetent numbers 0-99999999

expression

^ (/ d | -)? (/ d |,) * /.? / d * $

description

match:

Belt or noncompetent numbers 0-99999999

Match example

5,000

100,044

Mismatch example

123, 888, 888

1.1

0-65535 value

expression

^ ([0-5]? / D? / D? / D? / D | 6 [0-4] / d / d / d | 65 [0-4] / d / d | 655 [0-2] / d | 6553

[0-5]) $

description

0-65535 number

Match example

5000

100

Mismatch example

66666

-2

String verification

HTML and XML tag

expression

<[^>] >

description

All HTML and XML tags

Match example

5.0000

5000

Mismatch example

http://www.regexlib.com/add.aspx

String of ISBN format

expression

<[^>] >

description

String of the ISBN format.

Detailed definition: http://www.isbn.org/standards/html/usm4.htm

Match example

ISBN 0 93028 923 4

ISBN 1-56389-668-0

ISBN 1-56389-016-X

Mismatch example

http://www.regexlib.com/add.aspx

GUID

expression

^ [{| / (]? [0-9a-fa-f] {8} [-]? ([0-9A-FA-F] {4} [-]?) {3} [0-9A- FA-F] {12} [/) |}]? $

description

32-bit GUID in the following format:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx}

(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx))

Match example

914D226A-2F5B-4944-934D-96BBE6571977

{914D226A-2F5B-4944-934D-96BBE6571977}

Mismatch example

914D226A-2F5B-4944-XXXX-96BBE6571977

{914D226A-2F5B-4944-XXXX-96BBE6571977}

credit card number

expression

^ [{| / (]? [0-9a-fa-f] {8} [-]? ([0-9A-FA-F] {4} [-]?) {3} [0-9A- FA-F] {12} [/) |}]? $

description

16-digit

16-digit digital or spaces or split

Match example

1234343425262837

1111-2323-2312-3434

1111 2323 2312 3434

Mismatch example

1111 2323 2312-3434

Two identical words together

expression

(/ w ) / s / 1

description

Verify two of the same words together

Match example

ABC ABC

Mismatch example

ABC ABCD

Words in double quotes

expression

"(/ /") | [^ "(//")]) "

description

Verify the words enclosed with double quotes

Match example

"ABC"

ABC "SFF"

Mismatch example

SDFSDFSDF

mark

Verify 16-bit color values ​​in HTML

expression

^ #? ([A-F] | [A-F] | [0-9]) {3} (([A-F] | [A-F] | [0-9]) {3})? $

description

Verify the color value of 16 in HTML

# Is optional.

Match example

# 00ccff

FFFCC

Mismatch example

Blue

0x000000

Verify HTML code expressions containing JSP events

<[A-ZA-Z] [^>] * / SON / W = (/ W | '[^'] * '| "[^"] * ") [^>] *>

description

Verify HTML code containing JSP events

Match example

Mismatch example

IMG SRC = "star.gif"

Verify a pair of closed XML tags

expression

^ #? ([A-F] | [A-F] | [0-9]) {3} (([A-F] | [A-F] | [0-9]) {3})? $

description

Verify a rinc-enclosed XML tag.

Match example

text ... More text

link

Mismatch example

Blue

0x000000

Verify all legal ON events in HTML

expression

(? i: on (BLUR | C (Hange | Lick) | DBLClick | Focus | KeyPress | (Key | Mouse

(DOWN | UP) | (UN)? LOAD | MOUSE (MOVE | O (UT | Ver)) | RESET | S (ELECT | UBM

IT)))))))

description

Verify all legal ON events in HTML

Match example

Onclick

OnMouseover

Mismatch example

Click

Move

Find comments in HTML

expression

description

Find comments in HTML

Match example

this text has been removed ->

Mismatch example

this text Has Been Removed

Find specific files in HTML (swf.jpg.gif ...)

expression

<[^>] * / n?. * = ("| ')? (. * /. jpg) (" |')? * / n? [^ <] *>

description

Find specific files in HTML (swf.jpg.gif ...)

Change JPG to GIF, that is, look for all GIF files.

Match example

Mismatch example

= img.jpg

Date and time verification

Date verification

expression

^ (? :(? :(? :(? :( ?: 1 [6-9] | [2-9] / d)? (?: 0 [48] | [2468] [048] | [13579] [26]) | (? :( ?: 16 | [2468] [26]) 00))) (// | - | /.) (?: 0? 2/1 (? : 29))) | (? :(? :( ?: 1 [6-9] | [2-9] / d)? / D {2}) (// | - | /.) (? :( ? :( ?: 0? [13578] | 1 [02]) / 2 (?: 31)) | (? :( ?: 0? [1,3-9] | 1 [0-2]) / 2 (29 | 30)) | (? :( ?: 0? [1-9]) | (?: 1 [0-2])) / 2 (?: 0? [1-9] | 1 / d | 2 [0-8]))))))

description

Date of verifying the date of Y / m / d from 1600/1/1 - 9999/12/31

Match example

04/2/29

2002-4-30

02.10.31

Mismatch example

2003/2/29

02.4.31

00/00/00

Date and time verification

expression

^ (? = / d) (? :(? :(? :(? :( ?: 0? [13578] | 1 [02]) (/ | - | /.) 31) / 1 | (?: (?: 0? [1,3-9] | 1 [0-2]) (/ / | - | /.) (?: 29 | 30) / 2)) (? :( ?: 1 [6- 9] [2-9] / d)? / D {2}) | (?: 0? 2 (// | - | /.) 29/3 (? :(? :( ?: 1 [6- 9] | [2-9] / d)? (?: 0 [48] | [2468] [26]) | (? :( ?: 16 | [2468] [048] | [3579] 00))) | (? :( ?: 0? [1-9]) | (?: 1 [0-2])) (// | - | /.) (? : 0? [1-9] | 1 / d | 2 [0-8]) / 4 (? :( ?: 1 [6-9] | [2-9] / d)? / D {2}) ($ | / (? = / d)))))))))))))))))))))))))))))))))) (((0-15]) (: [0-5] / d) {0,2} (/ [AP] M) | ([01] / D | 2 [0-3]) (: [0-5] / d) {1, 2})? $ Description

Verify all legal date and time

Match example

20:20

04/2/29

02.4.31

02.10.312002-4-30

02.10.31

Mismatch example

2003/2/29

00/00/00

Standard ANSI SQL Date Verification

expression

^ ((/ d {2} (([02468] [048]))) [(((((((((((0? [13578]) | (1 [ 02]) [/ - /// s]? ((0? [1-9]) | ([1-2] [0-9]) | (3 [01]))) | (((0 ? [469]) | (11)) [/ - /// s]? ((0? [1-9]) | ([1-2] [0-9]) | (30))) | ? 0 2 [/ - /// s] ((0 [1-9]) | ([1-2] [0-9])?)))) | (/ d {2} (([02468? [1235679]) ([13579]) [(((((((0? [13578]) | (1 [02])) [/ - /// s] ((0? [1-9]) | ([1-2] [0-9]) | (((((((0? [469]) | (11)) [/ - /// s]? ((0? [1-9]) | ([1-2] [0-9]) | (30))) | (0? 2 [/ - /// s]? ((0 [1-9]) |? (1 [0-9]) | (2 [0-8])))))) (/ s (((0 [1-9]) |? (1 [0-2])) /: ([0-5] [0-9]) ((/ s) | (/: ([0-5] [0-9]) / s)))) ([AM | PM | AM | PM] {2,2})))))

description

Match the date format of ANSI SQL: YYYY-MM-DD HH: MI: SS AM / PM

It includes checking from 1901-2099 whether it is a leap year.

Match example

2004-2-29

2004-02-29 10:29:39 PM

2004/12/31

Mismatch example

04-2-29

04-02-29 10:29:39 PM

04/12/31

other

Match font

expression

^ (/ d) * () * (PX | PX | PX | PX | PT | PT | PT | Pt |) $

description

Find the suffix of the font

Match example

1px

100 Pt

20px

Mismatch example

1ABC

PX

1 SDFS

Match MD5 Haxi string

expression

^ (/ d) * () * (PX | PX | PX | PX | PT | PT | PT | Pt |) $

description

^ ([A-Z0-9] {32}) $

Match example

790D2CF6ADA1937726C17F1EF41AB125

Mismatch example

790D2CF6ADA1937726C17F1EF41AB125

Regex's related tools and Word documents can be found here. : // Xafile / Share / Public / Bond / Regex

PS:

This list will have been updated, I hope everyone can support it. Stick it in the useful regex.

J

转载请注明原文地址:https://www.9cbs.com/read-118679.html

New Post(0)