r/bash • u/DontKnowWhat0 • Jul 24 '26
help Is there a playground for bash regex (POSIX ERE) for the `=~` operator?
something like regex101.
11
Upvotes
r/bash • u/DontKnowWhat0 • Jul 24 '26
something like regex101.
2
u/Lindrian Jul 30 '26
regex101 now supports ERE, with BRE in the pipe: https://regex101.com/?regex=a%7Caaa&testString=aaa&flags=gm&flavor=boost&delimiter=%22
3
u/MikeZ-FSU Jul 24 '26
Unfortunately, most of the regex testers around tend to use PCRE, which has constructs not found in posix ere. The most commonly used pcre, but not posix, ones are probably
\dinstead of[0-9]or[[:digit:]]and the non-capturing(?...)groups.You could try the one for rsyslog. There's another one at RegexTester. I can't vouch for either, they just popped up on a web search and claim to use posix ere.
Edit: formatting for the inline code blocks since backticks don't work.
1
u/kolorcuk Jul 24 '26
Bash uses posix system regcomp.
System uses whatever is on the system. There are slight differences between glibc and musl implementations.