| View previous topic :: View next topic |
| Author |
Message |
momofsix Guest
|
Posted: Sun Nov 11, 2007 2:44 pm Post subject: Using Regex substring in function, is it possible? |
|
|
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
|
Posted: Sun Nov 11, 2007 5:05 pm Post subject: |
|
|
| 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 |
|
 |
momofsix Guest
|
Posted: Sun Nov 11, 2007 6:15 pm Post subject: |
|
|
| I've been working on this forever. I have been unsuccessful. RegEx is too hard. |
|
| Back to top |
|
 |
momofsix Guest
|
Posted: Sun Nov 11, 2007 6:23 pm Post subject: |
|
|
I want to find
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
|
Posted: Sun Nov 11, 2007 6:35 pm Post subject: |
|
|
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 |
|
 |
Xander
Joined: 23 Sep 2007 Posts: 142
|
Posted: Sun Nov 11, 2007 7:26 pm Post subject: |
|
|
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 |
|
 |
|