It would be very handy if regex was built into the language syntax itself as an embedded language mode. This would give you syntax errors to catch early if you have a mistake in your regex! (Of course also allow creating a regex from a string.)
I imagine the syntax looking something like this:
# If matched, $results is a list of capture groups. If not, then nil
$results = "my string" =~ re#\w+#
The tricky part is that forward slashes are often used as delimiters, but those mean directory separators far more often in a shell.
It would be very handy if regex was built into the language syntax itself as an embedded language mode. This would give you syntax errors to catch early if you have a mistake in your regex! (Of course also allow creating a regex from a string.)
I imagine the syntax looking something like this:
The tricky part is that forward slashes are often used as delimiters, but those mean directory separators far more often in a shell.