This is more of an issue with the HackBuilder render exporter, I think, but I can't figure out a way to render regex patterns without them being escaped.
For sake of example, say I have this string:
'/^\/?(\?.*)?$/'
The HackBuilderKeys renderer has four options:
literal
export
classname
lambda
Lambda and classname are right out since they don't apply, but neither literal nor export output the correct result for regex strings.
literal outputs:
/^\/?(\?.*)?$/
without any string wrapping (as expected and documented).
export outputs:
'/^\\/?(\\?.*)?$/'
after escaping all of the slashes in the string (which breaks the regex pattern).
Root cause of this is because export uses var_export to render the string pattern as you can see here which escapes strings.
I think best bet is to just have a specific case for a regex pattern since var_export works for most (if not all other) cases.
This is more of an issue with the HackBuilder render exporter, I think, but I can't figure out a way to render regex patterns without them being escaped.
For sake of example, say I have this string:
The HackBuilderKeys renderer has four options:
Lambda and classname are right out since they don't apply, but neither
literal
norexport
output the correct result for regex strings.literal
outputs:without any string wrapping (as expected and documented).
export
outputs:after escaping all of the slashes in the string (which breaks the regex pattern).
Root cause of this is because
export
usesvar_export
to render the string pattern as you can see here which escapes strings.I think best bet is to just have a specific case for a regex pattern since
var_export
works for most (if not all other) cases.