Closed mjfwalsh closed 4 years ago
I have no way to test that since I have no Mac, but it's a one-liner, so I trust it will do what you say. Thanks!
Happy to help. It's just one of those differences between regex implementations.
This is what Apple's re_format(7) manpage says:
ENHANCED FEATURES When the REG_ENHANCED flag is passed to one of the regcomp() variants, additional features are activated. Like the enhanced regex implementations in scripting languages such as perl(1) and python(1), these additional features may conflict with the IEEE Std 1003.2 (``POSIX.2'') stan- dards in some ways. Use this with care in situations which require portability (including to past versions of the Mac OS X using the previous regex implementation). For enhanced basic REs, `+', `?' and `|' remain regular characters, but `\+', `\?' and `\|' have the same special meaning as the unescaped characters do for extended REs, i.e., one or more matches, zero or one matches and alteration, respectively. For enhanced extended REs, back ref- erences are available. Additional enhanced features are listed below.
Given the option I'd probably go for an extended regex instead:
#define PREFIX "(^/|^\\./|^)"
On MacOS
-o subtree=<regexp>
currently fails as\?
only has a special meaning if the REG_ENHANCED flag is passed to regcomp.