Moderators SmOke_N Posted May 9, 2009 Moderators Share Posted May 9, 2009 (edited) Using \|? in the regex will always return a match even if there's no pipe... if that's the goal, then (.*?)\|? is fine. However, if you only want an array if there is a pipe in the string, then you'd be looking at something like (.*?)(?:\||\z) instead. Edit: Don't listen to my 42 hours of being up babble, mine will return the same thing as \|?! Edited May 9, 2009 by SmOke_N 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...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 it was just the difference between the results using Expresso and everything else :-using "one|two|" and the exp (.*?)\| , 3AutoIt returns :-onetwoRegulazy returns :-onetwoExpresso returns :-one|two|its just an odd result with that particular program thats all, dont like it myself its a bit confusing i prefer Regulazy to help build expressions i think. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Aceguy Posted May 9, 2009 Author Share Posted May 9, 2009 (edited) and i payed for expresso cant figure out reulazy Edited May 9, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
GEOSoft Posted May 9, 2009 Share Posted May 9, 2009 You have to also remember that there are differences in RegEx engines. AutoIt uses the PCRE engine and many of the tools available don't recognize the PCRE syntax. Always check to see what engines it supports. Example: If it says that it's for DOT NET Regexp then the reults will not always be accurate with PCRE. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 (edited) well it is fine as long as you remember its results have the end expression character(s) at the end of each result (for some reason)i think i misunderstood what you was saying about the end "|" though, you was not talking about how all the results returned from Expresso have the "|" but that yuo want one|two to return :-onetwowithout the last pipe! soz for misunderstanding , but what i said before still stands.well i cant figure out what the exp should be but i know what your after, i dont know how to say "break at "|" or end of string" kinda thing. Edited May 9, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 (edited) well after what seems like an age what about this :- $A_SRE=StringRegExp ($string,"(.*?)(?:\||\z)",3) i think it works just about, does give 1 extra NULL array entry at the end. EDIT:- GOT IT , WOOHOO (.+?)(?:\||\z) Edited May 9, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Aceguy Posted May 9, 2009 Author Share Posted May 9, 2009 (edited) GOOD WORK JackDinn.... i was sooooo close to finishing too.. This is using your code i had (\||\z) at the end which gave lots of NULL results $string="one|two|three|four|five|six|seven|testx testy | mary had a little lamb" $reg="(.*?)(?:\||\z)" $split = StringRegExp($string,$reg,3) _ArrayDelete($split,UBound($split)-1) _ArrayDisplay($split) Edited May 9, 2009 by Aceguy [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 np, if you didn't catch my EDIT i even found how not to get the extra NULL at the array end so $A_SRE=StringRegExp ($string,"(.+?)(?:\||\z)",3) == StringSplit ($string,"|") the delimiter is the "\|" but im sure your ok with it from here. no prob, glad to learn along with ya. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
GEOSoft Posted May 9, 2009 Share Posted May 9, 2009 (edited) Is this what you were looking for Jack "(?i)\|?\b(.+?)\b\|?" Edit: bettter yet "(?i)\|?\b([\w\s]+)\b\|?" Edited May 9, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Aceguy Posted May 9, 2009 Author Share Posted May 9, 2009 interesting results tho. $string="" $split="" for $x=1 to 5000 $string&=Random(100,100000,1)&"|" Next $timer=TimerInit() $split = StringRegExp($string,"(.*?)(?:\||\z)",3) $td=TimerDiff($timer) ConsoleWrite($td&" Reg Exp"&@Lf) $split="" $timer=TimerInit() $split=StringSplit($string,"|") $td=TimerDiff($timer) ConsoleWrite($td&" Stringsplit"&@Lf) [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 yep all 3 do the job , n1 to you to what a headache of a command Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
JackDinn Posted May 9, 2009 Share Posted May 9, 2009 interesting results tho. $string="" $split="" for $x=1 to 5000 $string&=Random(100,100000,1)&"|" Next $timer=TimerInit() $split = StringRegExp($string,"(.*?)(?:\||\z)",3) $td=TimerDiff($timer) ConsoleWrite($td&" Reg Exp"&@Lf) $split="" $timer=TimerInit() $split=StringSplit($string,"|") $td=TimerDiff($timer) ConsoleWrite($td&" Stringsplit"&@Lf)aye almost twice as fast to use stringsplit but then again thats what it was built for. but all good learning. Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Aceguy Posted May 9, 2009 Author Share Posted May 9, 2009 aye almost twice as fast to use stringsplit but then again thats what it was built for. but all good learning.yes, Learnt lots, thanks guys [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock 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