As far as I understand from the docs, STRING_MATCHES_REGEXP should match always the whole string; therefore
However, I have:
facepalm
0
1
What should I do, other than go through all my weidu code and add those '^' and '$' to make it work?
~%string%~ STRING_MATCHES_REGEXP ~%regexp%~
and
~%string%~ STRING_MATCHES_REGEXP ~^%regexp%$~
should always be equivalent, unless ~%regexp%~ ends with an odd number of '\' characters.However, I have:
BEGIN ~gist~
INSTALL_BY_DEFAULT
ACTION_IF ~~ STRING_MATCHES_REGEXP ~^ $~ THEN BEGIN
PRINT ~facepalm~
END
/** Space, tab and new line with an optional carriage return character before it if built on a windows system. */
OUTER_TEXT_SPRINT WHITESPACE_CHARS ~
~
/** Regexp for a sequence of ASCII white space characters. */
OUTER_TEXT_SPRINT WHITESPACE_RX ~\([%WHITESPACE_CHARS%]*\)~
/** Regexp for a character which is not ASCII white space. */
OUTER_TEXT_SPRINT NOT_WHITESPACE_RX ~\([^%WHITESPACE_CHARS%]*\)~
/** Regexp matching any sequence of '\' terminated by a character other than '"' and '\',
* or an odd sequence of '\' terminated by '"'. */
OUTER_TEXT_SPRINT JSON_STRING_ATOM_RX ~\(\\*[^\"]\|\([^\]\\\(\\\\\)*"\)\)~
/** Any string surrounded by a pair of '"' characters, in which all '"' are escaped with a '\'.*/
OUTER_TEXT_SPRINT JSON_STRING_RX ~"\(\(\\\(\\\\\)*"\)?\(%JSON_STRING_ATOM_RX%*\)\(\(\\\\\)*\)\)"~
DEFINE_ACTION_FUNCTION is_string
STR_VAR json = ~~
RET res
BEGIN
OUTER_SET res = 1
ACTION_IF ~%json%~ STRING_MATCHES_REGEXP ~^%WHITESPACE_RX%%JSON_STRING_RX%%WHITESPACE_RX%$~ THEN BEGIN
OUTER_SET res = 0
END
END
DEFINE_ACTION_FUNCTION is_string2
STR_VAR json = ~~
RET res
BEGIN
OUTER_SET res = 1
ACTION_IF ~%json%~ STRING_MATCHES_REGEXP ~%WHITESPACE_RX%%JSON_STRING_RX%%WHITESPACE_RX%~ THEN BEGIN
OUTER_SET res = 0
END
END
LAF is_string STR_VAR json = ~"""~ RET res END
PRINT ~%res%~
LAF is_string2 STR_VAR json = ~"""~ RET res END
PRINT ~%res%~
Even worse,
~~ STRING_MATCHES_REGEXP ~^ $~
Prints:facepalm
0
1
What should I do, other than go through all my weidu code and add those '^' and '$' to make it work?








