Several regular expressions

xiaoxiao2021-03-05  30

<%

REM ## Simple regular detection does not contain illegal characters

REM ## string to be tested

Rem ## badwordList filtering strings must be |

Function ishavebadword

(Str

BadwordList

)

DIM STRPATTERN

StrPattern

= BadwordList

&

" "

Dim OREGEX

omatch

SET OREGEX

= New

Regexp

Oregex

.

Ignorecase

= TRUE

'not case sensitive

Oregex

.

Global

= TRUE

Oregex

.

Pattern

= STRPATTERN

Set Omatch

= Oregex

.

EXECUTE

(Str

)

IF omatch

.Count

THEN

ISHAVEBADWORD

= TRUE

Else

ISHAVEBADWORD

= FALSE

End

IF

End

FUNCTION

Rem ## Simple regular replacement illegal characters, replaced by one *

REM ## string to be tested

Rem ## badwordList filtering strings must be |

Function ReplaceBadword

(Str

BadwordList

)

DIM STRPATTERN

StrPattern

= BadwordList

&

" "

Dim OREGEX

omatch

SET OREGEX

= New

Regexp

Oregex

.

Ignorecase

= TRUE

'not case sensitive

Oregex

.

Global

= TRUE

Oregex

.

Pattern

= STRPATTERN

Replacebadword

= Oregex

.

Replace

(Str

,

"*"

)

SET OREGEX

= Nothing

End

FUNCTION

Response

.

Write

(

"ASP Xiao Yue Dist]"

& Ishavebadword

(

"ASP Xiao Yue Dist]"

,

"xiaoyuehen | Xiao Yue marks"

)

&

"
"

)

Response

.

Write

(

"ASP Xiao Yue Dist]"

& Replacebadword

(

"ASP Xiao Yue Dist]"

,

"xiaoyuehen | Xiao Yue marks"

)

&

"
"

)

REM ## detects whether it is, the micro-sequence of numbers. Multi-selection submission detection available for forms

REM ## string to be tested

Function matchnumlist

(Str

)

DIM STRPATTERN

StrPattern

=

"^ [0-9] {1,} (, [0-9] ) {0,} $

Dim OREGEX

omatch

SET OREGEX

= New

Regexp

Oregex

.

Ignorecase

= TRUE

'not case sensitive

Oregex

.

Global

= TRUE

Oregex

.

Pattern

= STRPATTERN

Set Omatch

= Oregex

.

EXECUTE

(Str

)

IF omatch

.Count

THEN

Matchnumlist

= TRUE

Else

Matchnumlist

= FALSE

End

IF

End

Function

Response

.

Write

(

"6, 1245, 2122, 456"

& Matchnumlist

(

"6, 1245, 2122, 456"

)

&

"
"

)

Response

.

Write

(

"6, 1A45, 2122, 456"

& Matchnumlist

(

"6, 1A45, 2122, 456"

)

&

"
"

)

Response

.

Write

(

", 6, 1245, 2122, 456"

& Matchnumlist

(

", 6, 1245, 2122, 456"

)

&

"
"

)

Response

.

Write

(

"6, 1245, 2122, 456,"

& Matchnumlist

(

"6, 1245, 2122, 456,"

)

&

"
"

)

%

>

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

New Post(0)