Hawkwing Posted September 5, 2009 Share Posted September 5, 2009 I think I understand the basics of stringregexp, thanks to neogia's guide, but what if the test string has parentheses?So if the test string is "test(#)", and I want to have a pattern like "test([1-9])" how do I do that? The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
BrettF Posted September 6, 2009 Share Posted September 6, 2009 Hi There!This is what I came up with first, but we have a very obvious problem. It only returns what is between the parentheses.Dim $test[6] $test[0] = 5 $test[1] = "Test (100)" $test[2] = "Test (200)" $test[3] = "Test (300)" $test[4] = "Test (a400)" $test[5] = "Test (500)" For $x = 1 To $test[0] $array = StringRegExp($test[$x], "Test \((.*?)\)", 3) For $i = 0 To UBound($array) - 1 MsgBox(0, "RegExp Test with Option 2 - " & $i, $array[$i]) Next NextSo I refined the pattern to only return digits:Dim $test[6] $test[0] = 5 $test[1] = "Test (100)" $test[2] = "Test (200)" $test[3] = "Test (300)" $test[4] = "Test (a400)" $test[5] = "Test (500)" For $x = 1 To $test[0] $array = StringRegExp($test[$x], "Test \((\d.*?)\)", 3) For $i = 0 To UBound($array) - 1 MsgBox(0, "RegExp Test with Option 2 - " & $i, $array[$i]) Next NextI'm sure someone will come along with a better regular expression, but I hope this helps somewhat...Cheers,Brett Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
Hawkwing Posted September 6, 2009 Author Share Posted September 6, 2009 Thanks! Just went to the helpfile and found out what \ was for, should have done that before I posted The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
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