logoalt Hacker News

semanticctoday at 5:27 PM0 repliesview on HN

> So for my definition of “everywhere,” with the caveats mentioned above, the following features work everywhere. YMMV.

  .
  ^, $
  […], [^…]
  \*
  \w, \W, \s, \S
  \1 - \9 backreferences
  \b \B
  ? + 
  | alternation
  {n,m} for counting matches
  (...) capturing
Except that these don't work in macOS/BSD sed (even with -E flag):

- \w, \W, \s, \S - need to use POSIX classes instead: [[:alnum:]], [^[:alnum:]], [[:space:]], [^[:space:]]

- \b - need to use use [[:<:]] (word start) and [[:>:]] (word end) instead

- \B - (not a word start/end) no alternatives