summaryrefslogtreecommitdiffstats
path: root/bin/bre-invert-word
blob: 677ba2e97c14ea964b310b67c2924aad3b9f5efd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#! /bin/sh
# bre-invert-word : string -> BRE
set -euf

# TODO escape chars in the resulting BRE.
awk -v input="$1" '
  BEGIN {
    split(input,s,"")
    for (i in s) {
      c=s[i]
      printf "\\|%s[^%s]", y, c
      y = y c
    }
  }
'