Hello Maria,
Sparkout wakes me up to come here
Ok, some thoughts:
When testing the result of your regex, it would help to be a bit more precise,
so you should have seen that your code with matchText() doesnt' exactly returns what you think.
So you could try this one, instead:
Code: Select all
on mouseUp
get matchText(tTemp,"(?:((?:(?:[[:alpha:]]{1,5})))((?: ))((?:§§§))((?: ))((?:(?:[[:alpha:]]{1,5}))))", t1,t2,t3,t4,t5)
answer format("t1: %s t2: %s t3: %s t4: %s t5: %s", t1,t2,t3,t4,t5)
end mouseUp
Now, about the matchChunk(); you have missed in the dictionnary:
If the regularExpression includes a pair of parentheses, the position of the substring matching the part of the regular expression inside the parentheses is placed in the variables in the positionVarsList. The number of the first character in the matching substring is placed in the first variable in the positionVarsList, and the number of the last character is placed in the second variable. Additional starting and ending positions, matching additional parenthetical expressions, are placed in additional pairs of variables in the positionVarsList.
Therefore, either get rid of your t5 variable, or add a t6 one; like this one:
(See how I check the results of the regex; no surprises then)
Code: Select all
on mouseup
get matchChunk(tTemp,"(?:((?:(?:[[:alpha:]]{1,5})))((?: ))((?:§§§))((?: ))((?:(?:[[:alpha:]]{1,5}))))", t1,t2,t3,t4,t5,t6)
answer format("t1..t2: <%s>\nt3..t4: <%s>\nt5..t6: <%s>", char t1 to t2 of tTemp, \
char t3 to t4 of tTemp, char t5 to t6 of tTemp )
end mouseUp
And now, as I'm not really sure what you want to achieve; I assume
you are interested to catch the 2 words around your "§§§" string.
If this is true, then all your regex could be written this way:
Code: Select all
local tTemp = "blabla blablablabla bla bla hello §§§ world blaablaa"
get matchChunk(tTemp,"(\w+)\s§§§\s(\w+)", t1,t2,t3,t4)
answer format("t1..t2: <%s>\nt3..t4: <%s>", \
char t1 to t2 of tTemp, char t3 to t4 of tTemp )
get matchText(tTemp,"(\w+)\s§§§\s(\w+)", t1,t2)
answer format("t1: %s t2: %s", t1,t2)
Does it make sense?
Regards,
Thierry