AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using Regex substring in function, is it possible?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
momofsix
Guest





PostPosted: Sun Nov 11, 2007 2:44 pm    Post subject: Using Regex substring in function, is it possible? Reply with quote

Here is what I'm trying to do:
Quote:

Haystack = a75
Haystack := RegExReplace(Haystack, "(a)[0-9]+" , function($1))

function(substring)
{
MsgBox, % substring
; I want to get the substring in here so I can search in a database
based on it and use the search result as replacement string
}


Is it possible?
Back to top
tic



Joined: 22 Apr 2007
Posts: 1364

PostPosted: Sun Nov 11, 2007 5:05 pm    Post subject: Reply with quote

even if its not possible, which i havent checked, whats the problem? its only an extra line if its not possible to do it that way
Back to top
View user's profile Send private message
momofsix
Guest





PostPosted: Sun Nov 11, 2007 6:15 pm    Post subject: Reply with quote

I've been working on this forever. I have been unsuccessful. RegEx is too hard.
Back to top
momofsix
Guest





PostPosted: Sun Nov 11, 2007 6:23 pm    Post subject: Reply with quote

I want to find
Code:

/tnumber/t

I want it to be lazy.

How do I do this? I've tried a bunch of stuff and I've been reading all day.
I don't understand why this doesn't work:
Code:

FoundPos := RegExMatch(Haystack, "(?<=\t)\b[0-9]+\b(?=\t)", pattern)


I need help desperatly
Back to top
tic



Joined: 22 Apr 2007
Posts: 1364

PostPosted: Sun Nov 11, 2007 6:35 pm    Post subject: Reply with quote

If you just want to find a literal string then there is no need to do reverse lookups or any of that waffle...

Just search for a literal string:

Code:
FoundPos := RegExMatch(Haystack, "\Q/tnumber/t\E", pattern)
Back to top
View user's profile Send private message
Xander



Joined: 23 Sep 2007
Posts: 142

PostPosted: Sun Nov 11, 2007 7:26 pm    Post subject: Reply with quote

Give an example haystack and what you want to find. What you want is not clear.

Do you want to find "123" in something that looks like: "\tabc123\t" ?

If so, just use "\t[a-z]+(\d+)\t".
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group