AutoHotkey Community

It is currently May 25th, 2012, 9:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: June 27th, 2007, 9:02 pm 
i want to do something that is, essentially, RegExMatchAll

i have strings of text that go something like:

text text 123-456-789 text text 123-456-789 text text 123-456-789 text

i want to extract all the number sequences.

the description of RegExMatch makes me think i can do it with something like:

Code:
regexmatch(myvar, "(\d\d\d-\d\d\d-\d\d\d)", outvar)


...which would put all the results in outvar1, outvar2....


but it doesn't work. i get the first one, but not any others.

what am i doing wrong?

jack


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2007, 9:08 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8647
Location: Salem, MA
i think this was answered recently, but I can't find it - it may be in this thread:
http://www.autohotkey.com/forum/topic13545.html

I seem to remember a looping having to be done.

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2007, 6:01 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Here's an alternate suggestion, using two RegExReplace commands
Code:
outvar := RegExReplace(myvar, ".*?(\d\d\d-\d\d\d-\d\d\d)", "$1|")
outvar := RegExReplace(outvar, "(.*)\|.*$", "$1")

The result wll be all the ###-###-### paterns seperated by |s. So you can either use Loop Parse or StringSplit after that. The second RegExReplace just gets rid of the trailing | and any left over text after it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2007, 6:17 pm 
Offline

Joined: September 4th, 2004, 8:44 pm
Posts: 74
Location: UK
Quote:
outvar := RegExReplace(myvar, ".*?(\d\d\d-\d\d\d-\d\d\d)", "$1|")
outvar := RegExReplace(outvar, "(.*)\|.*$", "$1")



that's a neat idea. i'll give it a go.

thanks

jack


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: KenC, lblb, Yahoo [Bot] and 71 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group