 Michael Wodrich | with whom regulären squeeze out coming me The idea one own Testprogrammes.
Also wished I RexEx-expressions with Backslash automatically transfiguring let. my try enclosed. The Backslash with nachfolgendem double quotation marks must but from hand in Backslash+q transformed go.
Also müßen this The Escapezeichen off go, I otherwise The double Backslashes Yes not wiederfinde...
The Umwandler proposes automatically To, if nothing found watts - but only one Anzeigevergleich.
The Results go into editor loaded, the itself with *.TXT for zuständig holds (ShellExec).
!
RegEx_Tester
ex XProfan 10
Set("Escape",0)
Declare CR$, Qu$
CR$ = Chr$(13) + Chr$(10) Zeilenende
Qu$ = Chr$(34) double quotation marks
========== Suchmuster and Examples ==========
Declare Datei_Muster$, Datei_Test$
Datei_Muster$ = "(?wen)^[^~./:~*~?q<>~|]{1}[^/:~*~?q<>~|]{0,254}$"
Datei_Test$ = "abcd.jpg" + CR$ +
"a b239.abcd ef12983 298" + CR$ +
"a....23498" + CR$ +
".abcde.jpg" + CR$ +
"abcde?.jpg" + CR$ +
"c:\abcde.jpg" + CR$
Declare eMail_Muster$, eMail_Test$
eMail_Muster$ = "(?wen)^([a-zA-Z~d]+([-~.~w]*[a-zA-Z~d])*@([a-zA-Z~d][-~w]*[a-zA-Z~d]~.)+[a-zA-Z]{2,9})$"
eMail_Test$ = "joe@aol.com" + CR$ +
"ssmith@aspalliance.com" + CR$ +
"a@b.cc" + CR$ +
"joe@wrox.co.uk" + CR$ +
"joe@domain.info" + CR$ +
"e@eee.com" + CR$ +
"eee@e-e.com" + CR$ +
"eee@ee.eee.museum" + CR$ +
".@eee.com" + CR$ +
"@eee.com" + CR$ +
"eee@e-.com" + CR$ +
"eee@ee.eee.eeeeeeeeee" + CR$ +
"a@b" + CR$ +
"notanemail" + CR$ +
"joe@@." + CR$ +
"joe@123aspx.com" + CR$ +
"joe@web.info" + CR$ +
"joe@company.co.uk" + CR$
Declare Money_Muster$, Money_Test$
Money_Muster$ = "(?m)^(~x80|~x24|~xA3|~xA5|~x20AC|~x0024|~x00A3|~x00A5)?(([1-9]~d{0,2}(~,~d{3})*)|([1-9]~d*)|(0))(~.~d{2})?$"
Money_Test$ = "$1,234,567.89" + CR$ +
"1234567.89" + CR$ +
"1,234,567.89" + CR$ +
"$0.00" + CR$ +
"$1,2345,67.89" + CR$ +
"$1234,345,678.0" + CR$ +
"£1.25" + CR$ +
"¥15000" + CR$ +
"€4.37" Yes, the love Euro-characters...
Declare Tel_Muster$, Tel_Test$
Tel_Muster$ = "(~+~d *)?(~(~d+~) *)?~d+(-~d*)*"
Tel_Test$ = "Phone of AlkorSoft (project PayCash) is +7(812) 329-44-69"
Declare Url_Muster$, Url_Test$
Url_Muster$ = "(?i)" + ignoriere big/small
"((FTP|HTTPS|HTTP)://|www~.)" + log (without: www.)
"([~w~d~-]+:[~w~d~-]+@)?" + User / Password
"([^/~r~n:]+)" + TCP address or Domainname
"(:~d{1,5})?" + Portnummer
"(((/[%+~w~d~-~.]*)+)*)" + Unix-way
"(~?[^~s=&]+=[^~s=&]+(&[^~s=&]+=[^~s=&]+)*)?" + request- (GET) Parameter
"(#[~w~d~-%+]+)?" HTML-anchors (Bookmark)
Url_Test$ = "https://192.168.0.2:80/users/~fname.lname/file.ext" + CR$ +
"ftp://user1:pwd@www.domain.com" + CR$ +
"ftp://download-net curtain@www.domain.com" + CR$ +
"ftp://download-net curtain.com/the_file.zip" + CR$ +
"https://www.dom" + CR$ +
"www.domain.com" + CR$ +
"user1:pwd@domain.com" + CR$ +
"192.168.0.2/folder/file.ext" + CR$ +
"https://192.168.0.2/folder/file.ext" + CR$ +
"https://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/reconbackreferences.asp" + CR$ +
"https://www.domain.com/folder" + CR$ +
"https://www.domain.com/folder/" + CR$
========== Procedures ==========
Proc RegEx_Umformer
Please mind: the converter functions only, if The Escapezeichen off are !!!
too the reguläre expression must with Set("Escape",0) erfaßt been be.
Sonderfall: double quotation marks in the String supplant one by hand in q, the
becomes then here again changed.
RegEx-Escapezeichen:
xnn characters with the Hex-code nn (ASCII-Text)
x{nnnn} characters with the Hex-code nnnn (one byte for ASCII-Text and two Bytes for Unicode-characters
one tabulator (HT/TAB), gleichbedeutend How x09
Zeilenvorschub (NL), gleichbedeutend How x0a
Wagenrücklauf (CR), gleichbedeutend How x0d
f Seitenvorschub (FF), gleichbedeutend How x0c
a Alarm (bell) (BEL), gleichbedeutend How x07
e Escape (ESC), gleichbedeutend How x1b
\ Backslash self (treats the converter)
q XProfan: double quotation marks (treats the converter)
vordefinierte classes:
w one alphanumerisches characters inklusive "_"
W no alphanumerisches characters, too no "_"
d one numerisches characters
D no numerisches characters
s some wörtertrennendes characters (corresponds to [
f])
s no wörtertrennendes characters
Wortgrenzen:
finds a Wortgrenze (where w on W border)
B finds everything except of/ one Wortgrenze
Modifikatoren:
(?i) lead The Search Schreibweisen-unabhägig through
(?m) Behandle whom Zielstring as mehrzeiligen String. the means, ändere
The meanings of "^" and "$": but not only whom beginning or the end the
Zielstrings To find, becomes eachone Zeilenseparator within one Strings
recognized (mind too The Zeilenseparatoren)
(?s) Behandle whom Zielstring as single row. the means, that "." each
arbitrary characters finds, even Zeilenseparatoren, The it usually not found.
(?g) Modifikator for whom "Genügsam"-mode. through the exhibit go any subesquent
Operators in whom "Genügsam"-mode geschaltet. Standardmassig are any Operators
"gierig". If means the Modifikator (?-g) from is, then operates + How +?, * as *? etc.
comment:
(?#Text) "text" is comment (must no schliessende Klammer imply).
Parameters in$
Declare out$, i%
out$ = Translate$(in$,"\",Chr$(250)) clear any semidetached-Backslashes from the lane
out$ = Translate$(out$,"q",Chr$(34)) Sonderfall double quotation marks
out$ = Translate$(out$,"","~") ändere the Escapezeichen
out$ = Translate$(out$,Chr$(250),"") place whom desired Backslash again since
out$ = Translate$(out$,"[a-zA-Z0-9]","[a-zA-Z~d]")
out$ = Translate$(out$,"[0-9a-zA-Z]","[a-zA-Z~d]")
out$ = Translate$(out$,"[a-zA-Z0-9_]","[~w]")
out$ = Translate$(out$,"[_0-9a-zA-Z]","[~w]")
out$ = Translate$(out$,"[0-9]","[~d]")
out$ = Translate$(out$,"[^a-zA-Z0-9]","[^a-zA-Z~d]")
out$ = Translate$(out$,"[^0-9a-zA-Z]","[^a-zA-Z~d]")
out$ = Translate$(out$,"[^a-zA-Z0-9_]","[~W]")
out$ = Translate$(out$,"[^_0-9a-zA-Z]","[~W]")
out$ = Translate$(out$,"[^0-9]","[~D]")
Return out$
ENDPROC
Proc ZeigMal
Parameters Text$
Declare f$, hF&, B#
f$ = $TempDir + "TEMP_RegEx_Tester.txt"
Dim B#,Len(Text$)+1
String B#,0 = Text$
BlockWrite f$,B#,0,Len(Text$) Erstelle temp. File...
Dispose B#
ShellExec(f$,"open",1) show tappt im dunkeln on...
Repeat
hF& = FindWindow( "TEMP_RegEx_Tester" ) were To the Window there is...
Until hF& <> 0
Erase f$ and entferne The File again. with the editor can the Result nevertheless ensured be.
ENDPROC
Proc RegEx_Tester
Parameters RegEx$, Text$
Declare Erg$, s$, RestText$, Offset&, oldDeci%, index%
oldDeci% = Set("Decimals",0)
Offset& = 1
RestText$ = Text$
If Len(Text$) < 80
Erg$ = "Suchtext: " + Qu$ + Text$ + Qu$ + CR$
Erg$ = Erg$ + Space$(11) +
If(Len(Text$) >= 10,
MkStr$("1234567890",Len(Text$) 10) + Left$("1234567890",Len(Text$) mod 10),
Left$("1234567890",Len(Text$) mod 10)) + CR$ + CR$
Else
Erg$ = "Suchtext:" + CR$ + Text$ + CR$ + CR$
EndIf
Erg$ = Erg$ + "regulärer expression:" + CR$ + RegEx$ + CR$ + CR$
Erg$ = Erg$ + "Ergebnis:" + CR$
s$ = Match $(RegEx$,RestText$)
While s$ <> ""
Inc index%
Erg$ = Erg$ + "Match " + Str $(Index%) + ": " + Qu$ + s$ + Qu$ +
", Len: " + Str $(%MatchLen) +
", Pos: " + Str $(%MatchPos) +
", GesamtPos: " + Str $(Offset& + %MatchPos - 1) + CR$
Offset& = Offset& + %MatchPos + %MatchLen - 1
RestText$ = Mid$(Text$,Offset&,Len(Text$))
s$ = Match $(RegEx$,RestText$)
EndWhile
Ifnot index%
Erg$ = Erg$ + "*** no hits ***" + CR$ + CR$
Erg$ = Erg$ + "Wurden Perhaps The Escapezeichen not angepaßt? here a Gegenüberstellung." + CR$
Erg$ = Erg$ + "alt: " + Qu$ + RegEx$ + Qu$ + CR$
Erg$ = Erg$ + "neu: " + Qu$ + RegEx_Umformer( RegEx$ ) + Qu$ + CR$
EndIf
Set("Decimals",oldDeci%)
Return Erg$
ENDPROC
========== Hauptprogramm ==========
ZeigMal RegEx_Tester( "(?i)[e]+","Proc RegEx_Tester" )
ZeigMal RegEx_Tester( "(w+)?","Proc RegEx_Tester" ) to that testing
ZeigMal RegEx_Tester( Datei_Muster$, Datei_Test$ )
ZeigMal RegEx_Tester( eMail_Muster$, eMail_Test$ )
ZeigMal RegEx_Tester( Money_Muster$, Money_Test$ )
ZeigMal RegEx_Tester( Tel_Muster$, Tel_Test$ )
ZeigMal RegEx_Tester( Url_Muster$, Url_Test$ )
Set("Escape",1)
End
Best wishes Michael Wodrich |
|