Sign in to follow this  
Followers 0
Aceguy

stringregexp instead of stringsplit

33 posts in this topic




#include<array.au3>
$split = StringSplit("|one|two|three|four|five|six|seven|testx testy | mary had a little lamb","|")
_ArrayDisplay($split)
$split = StringRegExp("|one|two|three|four|five|six|seven|testx testy | mary had a little lamb","(.*?)\|",3)
_ArrayDisplay($split)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

"(.*?)\|?"


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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

but the regexp does not capture last string, any ideas.?

Which last string?

Oh.. i see

Could do this:

$split2 = StringRegExp("|one|two|three|four|five|six|seven|testx testy | mary had a little lamb" & "|","(.*?)\|",3)

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Which last string?

The way you had it "mary had a little lamb" would have been missed. You forgot the "?" after "|". I do it all the time too.

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

Share this post


Link to post
Share on other sites

The way you had it "mary had a little lamb" would have been missed. You forgot the "?" after "|". I do it all the time too.

I saw that after I posted that and corrected it, but does your solution work in the example I posted ?

Jos :)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#10 ·  Posted

Now that I have my eyes open... No.


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

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

i didn't understand why if you was picking up this question from my post this morning my post what was wrong with the $A_SRE=StringRegExp ($string,"\|?(.*?)\|" ,3) that was used in that post?

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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

but yea i know how you feel trying to learn StringRegExp (), iv been looking at it for the last 2 days & pcre pattern matching is a right pain to learn (well is for me :party: ) although i think iv got enough of a handle on it now to put it into use.

i found these helped a lot :-

regulazy

and this little app

g luck with it :)

p.s. ($string,"\|?(.*?)\|" ,3) worked fine with the test i did with that exact string

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

Share this post


Link to post
Share on other sites

#16 ·  Posted

post-12971-1241895751_thumb.jpgit works fine in autoit, but in expresso, i have been scratching my head for ages....

and as you can see, it returns the | at the end and doesnt return the last string ( i know i could put a | at the end) but wanted it to work like a proper Stringsplt

Share this post


Link to post
Share on other sites

#17 ·  Posted

hmm interesting , where did you get that program pls ?

odd why its returning the "|" but AutoIt dont and Regulazy dont either, maybe you have the flag not set to 3 "global matches" not sure but id like to have a look at that prog though as im learning SRE also.


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

Share this post


Link to post
Share on other sites

#19 ·  Posted

well weird, mine does return the last string but does also return the "|"'s to which it shouldn't.

must be something not set right here somewhere, cant really use the program if it dont return proper results :) but probably just missing something.


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

Share this post


Link to post
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
Sign in to follow this  
Followers 0