I am making a syntax module for the Rebol language and I am having trouble getting some keywords to match properly. This expression works:
match = "(action!|any-block!|any-function!|)"
but it is not ideal for I needed it to work with word boundaries. When I include word boundaries in the regex, the rule is never matched.
match = "\<(action!|any-block!|any-function!|)\>"
I think this is a problem with the exclamation point "!". I have tried using it with these escape sequences: !, \!, \041 \041; with no luck so far.
I had the same problem with keywords having the question mark "?" in them, ie:
match = "\<(about|abs|absolute|action?|add|alert|type?)\>"
Ideas would be most welcome. Is there a limitation in the regex engine?
Thanks, Jaime
On 26. Oct 2004, at 4:17, Jaime Vargas wrote:
match = "\<(action!|any-block!|any-function!|)\>"
I think this is a problem with the exclamation point "!". I have tried using it with these escape sequences: !, \!, \041 \041; with no luck so far.
The problem is that the exclamation point is not a word character, so there is no word boundary after the character, i.e. the pattern should be: match = "\<(action!|any-block!|any-function!)"
If you want to guard against word-characters _after_ the exclamation point, you could do: match = "\<(action!|any-block!|any-function!)(?!\w)"
But I think only the word-begin-boundary really matters in your case.
Kind regards Allan