TalksWithComputers wrote:
Here's what I meant:
Quote:
Billing Address
Firma:
Name: Jane Doe
Adresse : Some road 123
City :
...
Delivery Address
Firma: Acme inc
Name: Jane Doe
Adresse : Some other road 135
City :
Would it be possible to split the clipboard at "delivery address" into 2
variables for which separate Regexmatches could be done? This way one could omit the problem of having 2 identically named elements.
Stringsplit looks kind of promising. Any thoughts on that one?
StringSplit appears to split according to individual characters, so you can split with `r or `n, or `t or any of those three at once, but not a combination in a row. To do that you'd have to find the combination and convert it to a unused combination in your text. (Like Tilde ~ perhaps?)
If you do StringSplit, it might look something like this.
Code:
;note, stringreplace based on FIXED KNOWN patterns between your data.
;if you cannot guarantee the pattern, i don't recommend this.
StringReplace, text, clipboard, `r`n`r`n, ~, All
StringSplit, text, text, ~
;Text0 holds the number of matches found, so it's values would be Text1-TextN, where N is the number expressed in Text0
loop, %text0%{
;your code here with regex
;dealing with your haystack as text%a_index%
}
You can also loop like i mentioned before.
Code:
;starting position is 1. If there's a better way to do this,
;i'm interested in knowing, but this should work.
pos :=1
loop, {
;pos should point to starting of regex match now.
;match holds the contents of interest.
pos := regexmatch(haystack, needle, match, pos)
;no more patterns.
if pos = 0
break
;regex on 'match' and handle data.
;update starting location for next match.
pos += strlen(match)
}