$hGUI = GUICreate("正则表达式演示", 640, 360)
Global $X = 'C:\Users\Administrator\Desktop\desktop.ini'
Global $Y = GUICtrlCreateLabel("$String = 'C:\Users\Administrator\Desktop\desktop.ini'", 10, 10, 360)
GUICtrlCreateLabel("正则表达式", 10, 30)
GUICtrlCreateInput("StringRegExp($String, '^(\w)(?=:)',1)[0]", 10, 50, 356)
GUICtrlCreateInput("StringRegExp($String, '^(\w:)', 1)[0]", 10, 70, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w(:\V+)\\[^\\]+$', 1)[0]", 10, 90, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w:(\V+)\\[^\\]+$', 1)[0]", 10, 110, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w(:\V+\\)[^\\]+$', 1)[0]", 10, 130, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w:(\V+\\)[^\\]+$', 1)[0]", 10, 150, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w(:\V+)$', 1)[0]", 10, 170, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w:(\V+)$', 1)[0]", 10, 190, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w:\V+\\([^\\]+)$', 1)[0]", 10, 210, 356)
GUICtrlCreateInput("StringRegExp($String, '^\w:\V+\\([^\\]+)\.\w{2,4}$', 1)[0]", 10, 230, 356)
GUICtrlCreateInput("StringRegExp($String, '(?:\.\w{2,4})?$', 1)[0]", 10, 250, 356)
GUICtrlCreateInput("StringRegExp($String, '(?:\.(\w{2,4}))?$', 1)[0]", 10, 270, 356)
GUICtrlCreateInput("StringRegExp($String, '^.+(?=\\)', 1)[0]", 10, 290, 356)
GUICtrlCreateInput("StringRegExp($String, '^.+\\', 1)[0]", 10, 310, 356)
GUICtrlCreateInput("StringRegExp($String, '^.+(?=\.\w+$)', 1)[0]", 10, 330, 356)
$Z = GUICtrlCreateButton("切换", 590, 10, 40, 30)
GUICtrlCreateLabel("返回结果", 376, 30)
Global $A = GUICtrlCreateInput(StringRegExp($X, '^(\w)(?=:)', 1)[0], 376, 50, 254)
Global $B = GUICtrlCreateInput(StringRegExp($X, '^(\w:)', 1)[0], 376, 70, 254)
Global $C = GUICtrlCreateInput(StringRegExp($X, '^\w(:\V+)\\[^\\]+$', 1)[0], 376, 90, 254)
Global $D = GUICtrlCreateInput(StringRegExp($X, '^\w:(\V+)\\[^\\]+$', 1)[0], 376, 110, 254)
Global $E = GUICtrlCreateInput(StringRegExp($X, '^\w(:\V+\\)[^\\]+$', 1)[0], 376, 130, 254)
Global $F = GUICtrlCreateInput(StringRegExp($X, '^\w:(\V+\\)[^\\]+$', 1)[0], 376, 150, 254)
Global $G = GUICtrlCreateInput(StringRegExp($X, '^\w(:\V+)$', 1)[0], 376, 170, 254)
Global $H = GUICtrlCreateInput(StringRegExp($X, '^\w:(\V+)$', 1)[0], 376, 190, 254)
Global $I = GUICtrlCreateInput(StringRegExp($X, '^\w:\V+\\([^\\]+)$', 1)[0], 376, 210, 254)
Global $J = GUICtrlCreateInput(StringRegExp($X, '^\w:\V+\\([^\\]+)\.\w{2,4}$', 1)[0], 376, 230, 254)
Global $K = GUICtrlCreateInput(StringRegExp($X, '(?:\.\w{2,4})?$', 1)[0], 376, 250, 254)
Global $L = GUICtrlCreateInput(StringRegExp($X, '(?:\.(\w{2,4}))?$', 1)[0], 376, 270, 254)
Global $M = GUICtrlCreateInput(StringRegExp($X, '^.+(?=\\)', 1)[0], 376, 290, 254)
Global $N = GUICtrlCreateInput(StringRegExp($X, '^.+\\', 1)[0], 376, 310, 254)
Global $O = GUICtrlCreateInput(StringRegExp($X, '^.+(?=\.\w+$)', 1)[0], 376, 330, 254)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $Z
If GUICtrlRead($Y) = "$String = 'C:\Users\Administrator\Desktop'" Then
GUICtrlSetData($Y, "$String = 'C:\Users\Administrator\Desktop\desktop.ini'")
$X = "C:\Users\Administrator\Desktop\desktop.ini"
Else
GUICtrlSetData($Y, "$String = 'C:\Users\Administrator\Desktop'")
$X = "C:\Users\Administrator\Desktop"
EndIf
_RegExp()
EndSwitch
WEnd
Func _RegExp()
GUICtrlSetData($A, StringRegExp($X, '^(\w)(?=:)', 1)[0])
GUICtrlSetData($B, StringRegExp($X, '^(\w:)', 1)[0])
GUICtrlSetData($C, StringRegExp($X, '^\w(:\V+)\\[^\\]+$', 1)[0])
GUICtrlSetData($D, StringRegExp($X, '^\w:(\V+)\\[^\\]+$', 1)[0])
GUICtrlSetData($E, StringRegExp($X, '^\w(:\V+\\)[^\\]+$', 1)[0])
GUICtrlSetData($F, StringRegExp($X, '^\w:(\V+\\)[^\\]+$', 1)[0])
GUICtrlSetData($G, StringRegExp($X, '^\w(:\V+)$', 1)[0])
GUICtrlSetData($H, StringRegExp($X, '^\w:(\V+)$', 1)[0])
GUICtrlSetData($I, StringRegExp($X, '^\w:\V+\\([^\\]+)$', 1)[0])
GUICtrlSetData($J, Execute("StringRegExp($X, '^\w:\V+\\([^\\]+)\.\w{2,4}$', 1)[0]"))
GUICtrlSetData($K, StringRegExp($X, '(?:\.\w{2,4})?$', 1)[0])
GUICtrlSetData($L, StringRegExp($X, '(?:\.(\w{2,4}))?$', 1)[0])
GUICtrlSetData($M, StringRegExp($X, '^.+(?=\\)', 1)[0])
GUICtrlSetData($N, StringRegExp($X, '^.+\\', 1)[0])
GUICtrlSetData($O, StringRegExp($X, '^.+(?=\.\w+$)', 1)[0])
EndFunc ;==>_RegExp