by rethab on 7/18/20, 9:22 AM with 4 comments
by asicsp on 7/18/20, 1:24 PM
$ echo '# ' | awk 'match($0, /^#+ /, m){print length(m[0])-1}'
1
$ echo '### ' | awk 'match($0, /^#+ /, m){print length(m[0])-1}'
3
You can also use capture groups so that you do not need -1 and remove that substr as well. awk 'match($0, /^(#+) (.+)/, m){l=length(m[1]); print "<h" l ">" m[2] "</h" l ">"}'
by khm on 7/18/20, 7:53 PM
http://code.9front.org/hg/werc/file/2ace198c631b/bin/contrib...