Open
Description
🆒 Your use case
When working with simple character classes, I often find myself wanting to directly use traditional regex notation.
For example, I need to match any of whitespace, dash, or underscore characters.
With standard RegExp I can simply write /[-_\s]/
, but with magic-regexp I need to use a combination of anyOf(whitespace, charIn('-_'))
which produces a more complex pattern with capture groups and alternation.
🔍 Alternatives you've considered
anyOf(whitespace, charIn('-_'))
ℹ️ Additional info
A pattern
helper could allow direct use of regex notation when needed:
pattern('[-_\\s]').toString() // => "[-_\\s]"
refer to: https://github.com/slevithan/regex
This would maintain the type-safety and readability benefits of magic-regexp while allowing for more concise expressions in specific cases.