AutoHotkey Community

It is currently May 26th, 2012, 12:08 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: February 15th, 2008, 7:38 pm 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
I want to store in com1 the value 12 and in com2 the value 13

Why Is not correct?

Code:
string=a12ba13b
RegExMatch(string, ".*(?:a(.*)b).*", com)
msgbox, 1:%com1%`n2:%com2%

gives 13 only

this
Code:
RegExMatch(string, "(?:a(.*?)b)", com)

gives 12 only

_________________
____________________
______________________
kiu - www.romeosa.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2008, 8:05 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Code:
string = a12ba13b

RegExMatch(string, "(\d+)\D+(\d+)", com)
MsgBox, 1: %com1%`n2: %com2%

; OR you may prefer the following:
grep(string, "\d+", com_grep) ; see http://www.autohotkey.com/forum/topic16164.html
StringSplit, com_grep, com_grep, % Chr(4)
MsgBox, 1: %com_grep1%`n2: %com_grep2%

Thanks Skan for showing me this thread.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2008, 8:13 pm 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
thanks titan, but my problem is more generic and the code above was more specific, sorry

I mean to get, for example, 12 in com1 and anything <b>here</b> in com2 for

Code:
string=<a>12</a><a>anything <b>here</b></a>


or 1,2,3 in com1,com2,com3 respectively in

Code:
string=<a>1</a><a>2</a><a>3</a>

_________________
____________________
______________________
kiu - www.romeosa.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2008, 8:22 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Don't worry, I had suspected as much. That's why I gave sample code for the grep method - check it out.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2008, 8:29 pm 
Offline

Joined: December 18th, 2005, 5:40 pm
Posts: 234
Location: Italy - Galatro(RC)
thanks, I'll check

_________________
____________________
______________________
kiu - www.romeosa.com


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: dra, LazyMan, Leef_me, Tegno, Yahoo [Bot] and 45 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