Inline Regexes
On this page
Although Pomsky on its own is very powerful, there might be situations where its syntax is not
expressive enough. In these rare situations, Pomsky has an escape hatch: The regex
keyword allows
specifying an expression that is embedded in the output verbatim, without escaping:
regex 'hello|world?'
This emits the following regular expression:
hello|world?
This is dangerous and should only be used as a last resort. Pomsky does not parse the content of
regex
expressions, so it cannot ensure that the output is valid.For example, this is how you could use subroutines (which are not officially supported by Pomsky):
:octet(range '0'-'255') ('.' regex '\g<octet>'){3}
Note that Pomsky wraps a regex
expression in a non-capturing group if it is followed by a
repetition or surrounded by parentheses.
Finish line
This concludes the language tour! I hope