dcop Posted March 12, 2009 Posted March 12, 2009 Here are 2 strings that exist just like this... <TD>Matt Kenseth</TD>|<TD>Jimmie Johnson</TD> I would like to match them just using substring and I want to do it with StringRegExp Heres what I have <codebox> If StringRegExp($aPicks[$i], ' (Kenseth|Johnson)') <> 0 Then _ArrayDelete($aPicks, $i) </codebox> I've tried many things but I guess I just dont get it. TIA, Dennis
jvanegmond Posted March 12, 2009 Posted March 12, 2009 So? #include <Array.au3> $var = "<TD>Matt Kenseth</TD>|<TD>Jimmie Johnson</TD>" $a = StringRegExp($var, '<TD>(.*?)</TD>', 3) _ArrayDisplay($a) github.com/jvanegmond
dcop Posted March 12, 2009 Author Posted March 12, 2009 So? #include <Array.au3> $var = "<TD>Matt Kenseth</TD>|<TD>Jimmie Johnson</TD>" $a = StringRegExp($var, '<TD>(.*?)</TD>', 3) _ArrayDisplay($a) I am sorta of accomplishing that with.... CODEIf StringRegExp($aPicks[$i], '(<TD>Matt Kenseth</TD>|<TD>Jimmie Johnson</TD>') <> 0 Then _ArrayDelete($aPicks, $i) ...but I would like to just match the short string I mentioned and the string with TD's may not always be consistent but the kenseth and johnson will.
ProgAndy Posted March 12, 2009 Posted March 12, 2009 try this pattern: "(Kenseth)|(Johnson)" the or-operator just works for the 2 characters left/right of it. If you want to use it for multiple chars, you have to group them (non-matching groups work, too: "(?:Kenseth)|(?:Johnson)" ) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
dcop Posted March 12, 2009 Author Posted March 12, 2009 try this pattern:"(Kenseth)|(Johnson)"the or-operator just works for the 2 characters left/right of it. If you want to use it for multiple chars, you have to group them (non-matching groups work, too: "(?:Kenseth)|(?:Johnson)" )Thnan Andy! "(?:Kenseth)|(?:Johnson)|(?:Gordon)|(?:Logano )|(?:Edwards)" worked great!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now