Jump to content

stringregexp instead of stringsplit


Recommended Posts

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!"

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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!"

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

iv noticed that if you open the tree for each result it dont have the following "|" it seems to always put the ending exp character in the results for some reason?

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

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
 Share

  • Recently Browsing   0 members

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