File tree Expand file tree Collapse file tree 6 files changed +13
-8
lines changed Expand file tree Collapse file tree 6 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -123,9 +123,12 @@ The following commands are available:
123
123
<dt ><tt >REGEX(< ; value> ; str [, < ; variable> ; name])</tt ></dt >
124
124
125
125
<dd >Match the extended regular expression 'str', which must be of
126
- string type. Matching is performed greedily, while '.' (a dot)
127
- does not match a newline. Optionally assign the matched string to
128
- variable 'name'.</dd>
126
+ string type. Matching is performed greedily and '.' (a dot)
127
+ matches a newline, use <tt>[^\n]</tt> to work around this.
128
+ Optionally assign the matched string to variable 'name'. Note that
129
+ since some string characters have to be escaped already, you might
130
+ need to double escape them in a regex string. For example, to
131
+ match a literal backslash, enter <tt>\\\\</tt>.</dd>
129
132
130
133
<dt ><tt >ASSERT(< ; test> ; condition)</tt ></dt >
131
134
Original file line number Diff line number Diff line change @@ -1089,7 +1089,7 @@ void checktoken(command cmd)
1089
1089
1090
1090
else if ( cmd.name ()==" REGEX" ) {
1091
1091
string str = eval (cmd.args [0 ]).getstr ();
1092
- regex regexstr (str);
1092
+ regex regexstr (str,regex::extended );
1093
1093
match_results<string::const_iterator> res;
1094
1094
string matchstr;
1095
1095
Original file line number Diff line number Diff line change 1
1
SET(foo="bar.*")
2
2
STRING(foo) NEWLINE
3
- REGEX(foo) NEWLINE
3
+ REGEX(foo) # Note that '.' also matches newlines and ERE is greedy.
Original file line number Diff line number Diff line change 1
1
REGEX("\\\\(foo|(bar|baz))\
2
- x\n[\\.-\\ }]") NEWLINE
2
+ x\n[.- }]") NEWLINE
Original file line number Diff line number Diff line change 1
- REGEX(".*") NEWLINE
1
+ # Note that ERE '.' also matches newlines!
2
+ REGEX("[^\n]*") NEWLINE
2
3
SET(a=1/2)
3
4
ASSERT(a == 0.5)
Original file line number Diff line number Diff line change 1
- REGEX(".*") NEWLINE
1
+ # Note that ERE '.' also matches newlines!
2
+ REGEX("[^\n]*") NEWLINE
2
3
SET(a=1/2.)
3
4
ASSERT(a == 0.5)
You can’t perform that action at this time.
0 commit comments