trying to get 'sed' to work

Regex is still mysterious to me, except some basics it's foggy in my brain.
^(# +) every lines that start with # followed by a white space at least ---> okay for me
(Defaults passpr.*) the line must contain the string "Default blabla" plus anything behind it ---> okay for me
/\2/' but this I do not understand ?
Could you explain it to me please, thank you.

Remember that there are two versions of regex to use: basic (BRE) and extended (ERE) with the various binaries available. I think unless one has a specific reason to use basic, one should always prefer using extended as its syntax provides more flexibility.

Remember to use character classes ([[:alpha:]]+) rather than range groups (e.g. [a-zA-Z]+) as the former doesn't require the locale to be set correctly for matching to work.

I found reading these manpages helpful:

environ(7)()
localeconv(3)()
ctype(3)()
ascii(7)()
re_format(7)()
regex(3)()

Perhaps Sed - An Introduction and Tutorial by Bruce Barnett will be helpful (also: awk); especially because these are UNIX centered. Anyways, happy regexing :)

Regular expressions may seem easy at first but they have some intricate details and getting them right and executing them fast when necessary requires knowledge. The "ultimate" reference in regular expressions cross language and cross applications used to be Mastering Regular Expressions, 3rd Edition - 2006, don't know how well that works for modern versions of say, perl or java.

Thanks for these book suggestions.
 
Back
Top