Jump to content

Recommended Posts

  • Moderators
Posted (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 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.

Posted

it was just the difference between the results using Expresso and everything else :-

using "one|two|" and the exp (.*?)\| , 3

AutoIt returns :-

one

two

Regulazy returns :-

one

two

Expresso 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

Posted

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!"

Posted (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 :-

one

two

without 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 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

Posted (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 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

Posted (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 by Aceguy
Posted

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

Posted (edited)

Is this what you were looking for Jack

"(?i)\|?\b(.+?)\b\|?"

Edit: bettter yet

"(?i)\|?\b([\w\s]+)\b\|?"

Edited 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!"

Posted

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)
Posted

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

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
  • Recently Browsing   0 members

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