I want to find all standalone substrings that consist of a single lowercase "x", followed by any number of uppercase letters, followed by a space. Here's what I'm trying:
<$srch=" x[A-Z]+ " ">>=x[A-Z]+ ">
<$data="some words xHITWORD more words">
<rex ROW $srch $data>
Token found: [$ret]<br>
</rex>
This does NOT find the substring xHITWORD. What am I doing wrong?
Remember repetition operators apply to as much as they can, not just the previous character. The + after your character class indicates "more than one occurence of 'x followed by [A-Z]'"
Note that if you don't want to include the spaces in the matched data (but still use them to perform the match), you can use the Previous & Following flags like this:
<$srch=" \P=x=[A-Z]+\F =" ">>=x=[A-Z]+\F =">
Running the command line `rex -x expr' is also useful when figuring out what `expr' really means to REX: it translates the expression to human-readable pseudocode.