I'm looking for something similar to an online regex tester where I can experiment with the regular expressions used by Bash's =~ operator. Since Bash uses POSIX Extended Regular Expressions rather than PCRE, I'd like a tester that matches Bash's behavior as closely as possible, including its parsing quirks.
4 Answers
The exact behavior can vary slightly between systems because Bash relies on the platform’s regex library. For example, implementations based on glibc and musl may differ in some corner cases, so a local test on the target system is still the final authority.
A lot of online regex testers default to PCRE, which can be misleading. POSIX ERE does not support shortcuts such as d or constructs like (?...) for non-capturing groups, so use [[:digit:]] or [0-9] instead. There are a few testers that claim to support POSIX ERE, and running a small script in an online Bash environment is another practical option.
Bash’s =~ operator uses POSIX ERE through the system’s regcomp implementation. The same general syntax is used by tools such as grep -E, egrep, awk, and sed -E, so an online Bash shell runner or POSIX ERE tester should work reasonably well. Just remember that spaces may need escaping because Bash parses the expression before passing it to the regex engine. POSIX ERE does not provide many PCRE features, including lazy quantifiers, lookarounds, non-capturing groups, named groups, and the usual b word-boundary syntax.
PCRE is generally more feature-rich and overlaps with most ordinary ERE patterns, but it isn’t a perfect substitute. A pattern that works in PCRE can still rely on unsupported syntax or different edge-case behavior when used by Bash. Testing with the actual Bash implementation is the safest approach when compatibility matters.

That makes sense. I’ll use a POSIX-oriented tester for quick experiments and verify anything important with Bash itself.