Jump to content

Random samples of StringRegExp


jefhal
 Share

Recommended Posts

Don't ask why I did this, I was just obsessive tonight:

To find IP address in any text string:
StringRegExp($MyString1,'((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])\.(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9]))',3)
To find "text" or "test":
StringRegExp("text", 'te[sx]t'))
StringRegExp("text", 't{1}e{1}[sx]{1}t{1}'))
Other samples gleaned from this forum:
StringRegExp("aaaabbbbcccc", 'b{4}'))
StringRegExp("This is a test example", '(test)', 1)
StringRegExp("This is a test example", '(te)(st)', 1)
StringRegExp("The Sopranos @ -- Found KasAThoy", "(.*(?i)sopranos.*kasa(?i).*)"))
StringRegExp("Gnarly Monster hits you for 18 damage.", '([0-9]{1,3})', 1)
StringRegExp("You deflect 36 of Gnarly Monster's 279 damage.", '([0-9]{1,3})(?: damage)', 1)
StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
StringRegExp("aeiou", "([a-z])", 3 )
StringRegExp(GUICtrlRead($ebTest), GUICtrlRead($ebRegExp), $nMode)
StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
StringRegExp(StringStripWS(StdoutRead ($ipHandle), 3), '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3)
StringRegExp ( $s_array[$pos], $reg_exp[b][/b]ression, 1 )
StringRegExp($s_Bfile, 'base64,(.+?)" LAST_CHARSET', 3)
StringRegExp($MS_KB_Reg_Value,"\<KB\A+")
StringRegExp($s_String, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
StringRegExp($sVarStr, '(?:\$\[)(\d*)(?:\]\$)(\#)', 1)
StringRegExp($StdOutReadValue, '(?:MsgBoxSays)(.*?)(?:Return)', 3)
StringRegExp($somestring, "[a-z]{1," & StringLen($somestring) & "}")
StringRegExp($s_IE, "<A(.*?)>", 3)
StringRegExp(StringStripWS(StdoutRead ($ipHandle), 3), '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3)
StringRegExp($nStr, "^(\d{1,3}?)(\d{3})+(\p\d+)?$", 1)
StringRegExp($email, '^[_A-Za-z0-9-]+(\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})', 3)
StringRegExp($a_filelist[$i],'('&$s_serial&'_[0-9]{1}_[0-9]{14}.log)',1)
StringRegExp($TodayFile, '(?:ALT=""></td>[:space:]*?<TD VALIGN="top"  CLASS="obsTextA">)(.*?)(?:[:space:]*)?(?:<)', 3)
StringRegExp($TodayFile, '(?:WIDTH=52 HEIGHT=52 BORDER=0 ALT=><BR><B CLASS=obsTextA>)(.*?)(?:</B>)', 3)
StringRegExp($TodayFile, '(?:<B CLASS=obsTempTextA>)([:digit:]+)(?:.+;F</B><BR><B CLASS=obsTextA>Feels Like<BR>\s+)([:digit:]+)(?:.+?;F</B></DIV></TD>)', 3)
StringRegExp("fat fet fit fot fut", '(f[e]t|f[o]t)', 3)
StringRegExp('faat feet fiit foot fuut', '(f[e][e]t|f[o][o]t)', 3)
StringRegExp("fat fet fit fot fut", '(fet|fot)', 3)
StringRegExp('faat feet fiit foot fuut', '(feet|foot)', 3)
StringRegExp("faat feet fiit foot fuut", '(f(ee|oo)t)', 3)
StringRegExp("faat feet fiit foot fuut", '(f[e|o]{2}t)', 3)
StringRegExp("need faat feet fiit foot fuut loot hoot", '([a-z][e|o]{2}[a-z])', 3)
StringRegExp("need faat feet fiit foot fuut loot hoot sheeze", '([a-z]{1, 2}[e|o]{2}[a-z]{1, 2})', 3)
StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a{1,2}[e|o]{2}\a{1,2})', 3)
StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a*[e|o]{2}\a*)', 3)
StringRegExp("need faat feet fiit foot fuut loot hoot Sheeze", '(\a*[e*|o*]\a*)', 3)
StringRegExp("Theee  always was work.", "^The*\s+\w+ was \w+[.]$", 0 )
StringRegExp($data, $regexp,3)
StringRegExp( $MyFile , $Good )," = " ," != " )
StringRegExp( $MyFile , $NotGood )," = " ," != " )
StringRegExp($a_filelist[$i],'('&$s_serial&'_[0-9]{1}_[0-9]{10}.log)',1)
StringRegExp($currentRead, '(.*?)([:alpha:]:.*\.[a-zA-Z]{3})',3)
StringRegExp($FontNamesString, '(?i)\[(\s*?'&$searchstring&'.*?):\s(.*?)\s\]', 3)
StringRegExp($page_source, '(http://.*?/rendered/.*?\..{3})', 1)
StringRegExp($page_source, '(?:http://.*?/rendered/)(.*?\..{3})', 1)
StringRegExp($string, '([:digit:]*)',3)
StringRegExp($h_FRead, '(?:' & $s_Start & ')(.*?)(?:' & $s_End & ')', 3)
StringRegExp($h_FRead, '(?i:' & $s_Start & ')(.*?)(?i:' & $s_End & ')', 3)
StringRegExp($10DayFile, '(?:"padding:0px 3px 0px 0px;">)([a-zA-Z]*\s?[a-zA-Z]*?)(?:</TD>)',3)
StringRegExp(StringRegExpReplace($10DayFile, '(?:"padding:0px 3px 0px 0px;">)([a-zA-Z]*)\s?([a-zA-Z]*?)(?:</TD>)', '\1' & @CRLF & '\2', 0), '(?:"padding:0px 3px 0px 0px;">)([a-zA-Z]\r\n[a-zA-Z]*?)(?:</TD>)',3)
StringRegExp('IsBinaryString($value)', '([^"]+|"[^"]*")*', 1)
StringRegExp('Is"Binary"String("value")', '(?:(.*?)(".*?"))*|(.*)', 1)
StringRegExp('IsBinaryString(value)', '(?:(.*?)(".*?"))*|(.*)', 1)
StringRegExp('IsBinaryString($value)', '([^"]+|"[^"]*")*', 1)
StringRegExp('Is"Binary"String("value")', '(?:"([^"]*)")*', 3)
StringRegExp('string "one" and "two" and "three" and four', '([^"]+|"[^"]*")*', 1)
StringRegExp($str, 'Isle: (.*?)\r\nPosition: (.*?):(.*?):(.*?)\r\nRuler: (.*?)\r\nAlliance: (.*?)\r\nScore: (.*?)\r\nColony: (.*?)"', 3)
StringRegExpReplace($CmdLineRaw,"[^a-zA-Z0-9ÄÖÜäöüß\-_."&Chr(34)&" ]","")
StringRegExp($line, '#~ # [0-9]{1,2}') Or StringRegExp($line, '# [0-9]{1,2}')
Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Funny the rendering of the autoit tag with emoticons inside :D

Shall I call "The Guiness Book of Unexplainable Phenomenon"?.
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

  • Moderators

Hey, I see a couple of mine in there :D ... at first I had no idea what the hell you were doing :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...