As title says, trying to get 2 different regex codes:
1 code) Extract the 7 words before and after every '$' in a string. (include the # attached to each '$")
2nd code) Extract the 7 words before every '$', and all the words after the '$' leading up to a period. (include the # attached to each '$")
None of these below have worked. (found them around and tweaked).
Code: Select all
((?:\p{Xwd}+\P{Xwd}){0,7})\$((?:\P{Xwd}\p{Xwd}+){0,7})
([a-zA-z\s+){0,7}\$([a-zA-z\s+){0,7}
([^ ]+ ){0,7}\$( [^ ]+){0,7}
1) the code only detects the FIRST '$' in the string even when string has multiple '$' that should be detected
2) it only gets the words before that first '$', never any words after it.
3) When I implement them into autohotkey for an array, the msgboxes that appear have 1 less character (from the far left) than the previous msgbox, not sure why that is. So with each new msgbox that pops up, it's the same thing as previous msgbox but 1 character from the far left is deleted.
Here's what it all looks like in my AHK.:
Code: Select all
numm := []
test := so this is just a test ok testing $5 dollars for that ice-cream sandwhich is not bad at all. And also another sentence to test $10 thousand for an ice-cream sand which ain't bad either.
regex := "((?:\p{Xwd}+\P{Xwd}){0,7})\$((?:\P{Xwd}\p{Xwd}+){0,7})"
While pos := RegExMatch(test, regex, y, pos ? pos + 1 : 1)
numm.Push(y)
For each, n in numm
one := numm[1] ; should contain: this is just a test ok testing $5 dollars for that ice-cream sandwhich is not
two := numm[2] ; should contain: all. And also another sentence to test $10 thousand for an ice-cream sand which ain't
MsgBox % one
MsgBox % two
return