weaponx Posted June 12, 2008 Share Posted June 12, 2008 Well having that said then all I should have to do is add Global for $text in the process() No you should be using SmOke_N's code from the beginning of this thread... #include <array.au3> $var = "text|123;text|456;text|789" $aSRE = StringRegExp($var, "(?s)(?m:^|;)(.+?)\|", 3) _ArrayDisplay($aSRE) Link to comment Share on other sites More sharing options...
AustrianOak Posted June 12, 2008 Author Share Posted June 12, 2008 Naw, I have never even used StringRegExp() and now that I have, I hate it with a passion. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 12, 2008 Moderators Share Posted June 12, 2008 Naw, I have never even used StringRegExp() and now that I have, I hate it with a passion.I think we all hate it when we first start with it. I fought not to use it for some time, but as I saw 60 line functions reduced to 1 line of code I realized it was time I start to understand it.I have said this to others, but I'll publicly state it. If you plan on doing future string manipulations, it's worth putting your projects on hold for a few days to read everything you can on Regular Expressions.The hours you put into learning it will be returned when writing future code, your proficiency will increase, and the overall dynamics will flow much smoother. 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 More sharing options...
weaponx Posted June 12, 2008 Share Posted June 12, 2008 I think it would be beneficial if someone would update the StringRegExp() area of the help file. There are a lot of examples missing that PCRE supports:http://www.regular-expressions.info/reference.htmlhttp://www.regular-expressions.info/refadv.htmlNative StringSplitRegExp() would also be great. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 12, 2008 Moderators Share Posted June 12, 2008 I think it would be beneficial if someone would update the StringRegExp() area of the help file. There are a lot of examples missing that PCRE supports:http://www.regular-expressions.info/reference.htmlhttp://www.regular-expressions.info/refadv.htmlNative StringSplitRegExp() would also be great.I've been asked, but certainly don't have the time to write a "good" one.... You have a grasp on it, maybe you should . 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 More sharing options...
crashdemons Posted June 13, 2008 Share Posted June 13, 2008 (edited) StringRegExp would be the better way to do this but, for the sake of explanation: Array of 'text' #include <Array.au3> _ArrayDisplay(process('text|123;text|456;text|789')) Func process($string) $buf='' $delim1=StringSplit($string,';') $max=UBound($delim1)-1 For $i=1 To $max $delim2=StringSplit($delim1[$i],'|') $buf&=$delim2[1] If $i<$max Then $buf&='|' Next Return StringSplit($buf,'|') EndFunc Array of 'number' #include <Array.au3> _ArrayDisplay(process('text|123;text|456;text|789')) Func process($string) $buf='' $delim1=StringSplit($string,';') $max=UBound($delim1)-1 For $i=1 To $max $delim2=StringSplit($delim1[$i],'|') $buf&=$delim2[2] If $i<$max Then $buf&='|' Next Return StringSplit($buf,'|') EndFunc Note: process() assumes the data string isn't malformed from the original syntax given (text|num;text|num) Edited June 13, 2008 by crashdemons My Projects - WindowDarken (Darken except the active window) Yahsmosis Chat Client (Discontinued) StarShooter Game (Red alert! All hands to battlestations!) YMSG Protocol Support (Discontinued) Circular Keyboard and OSK example. (aka Iris KB) Target Screensaver Drive Toolbar Thingy Rollup Pro (Minimize-to-Titlebar & More!) 2D Launcher physics example Ascii Screenshot AutoIt3 Quine Example ("Is a Quine" is a Quine.) USB Lock (Another system keydrive - with a toast.) 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