Regular expressions, which can be understood as character matching or search techniques, are important in the notation of the pattern attribute.
*--determine if it is a mobile phone number
Function Ismobiphone
Lparameters CSTR
Oregexp=newobject ("Qyregexp", "PRG\QYREGEXP.PRG")
Oregexp.pattern= "1\d{10}" && represents 1, matched 10 digits are numbers
Oregexp.ignorecase=. T.
Return Oregexp.test (CStr)
Endproc
*--to determine if it is an e-mail address
Function isemailaddr (Tcemai)
Local Oregexp
Oregexp=createobject ("Qyregexp")
Oregexp.pattern = "^ (([a-za-z0-9]+_+) |";
+ "([a-za-z0-9]+\-+) |";
+ "([a-za-z0-9]+\.+) |";
+ "([a-za-z0-9]+\++)) *";
+ "[A-za-z0-9][email protected] ((\w+\-+) |";
+ "(\w+\.)) *\w{1,63}\. [A-za-z] {2,6}$ "
Return Oregexp.test (Tcemai)
Endfunc
Whether the *--global property finds the full string ignorecase property ignores case
The *--pattern property sets or returns a regular expression for searching on the Web site
The *--test method performs a regular expression search on a string and returns a Boolean value that indicates whether the match succeeded
*--replace This method is used to replace the text found in the regular expression search
*--execute This method applies a regular expression to a string and returns the matches array in the current class
Define Class Qyregexp as Custom
pattern= "*"
Dimension Matches (a)
Matches=. F.
Global=. T.
Ignorecase=. F.
oregexp=. F.
Procedure Clear
This.pattern = "*"
This.matches =. F.
Endproc
Procedure Test
Lparameters CSTR
Local Loregexp
Loregexp=createobject ("VBScript.RegExp")
Loregexp.global=this.global
Loregexp.ignorecase=this.ignorecase
Loregexp.pattern=this.pattern
Return Loregexp.test (CSTR)
Endproc
Procedure Replace
Lparameters Cstr,creplacestr
Local Loregexp
Loregexp=createobject ("VBScript.RegExp")
Loregexp.global=this.global
Loregexp.ignorecase=this.ignorecase
Loregexp.pattern=this.pattern
Return Loregexp.replace (CSTR,CREPLACESTR)
Endproc
Procedure Execute
Lparameters Tcstr
Local Lomatch, Lomatches, I
Local Loregexp
Loregexp=createobject ("VBScript.RegExp")
Loregexp.global=this.global
Loregexp.ignorecase=this.ignorecase
Loregexp.pattern=this.pattern
Lomatches = Loregexp.execute (TCSTR)
Dimension This.matches[max (lomatches.count,1), 2]
Tamatchinfo =. F.
i = 1
For each lomatch in lomatches
This.matches[i, 1] = Lomatch.firstindex + 1 && Fox strings is not zero-based
This.matches[i, 2] = Lomatch.value
i = i + 1
ENDfor
Lomatches =. F.
Loregex =. F.
Return i-1
Enddefine
Expand Ask Read here
Http://www.baidu.com/link?url=VT-ZYtKQjECWcCwBZ_4UKKXLyq_B5JNbYIGHla-HyvXEco4VPmXISGUVOlge_ZXS_PC3EtdWgFDLb5-AlTzXBa