PCRE Regex to SED

Want PCRE (Perl Compatible Regular Expressions)? Why don’t you use perl instead?

perl -pe 's/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g' \
    <<< "My email is abc@example.com"

Output:

My email is [emailaddr]

Write output to a file with tee:

perl -pe 's/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g' \
    <<< "My email is abc@example.com" | tee /path/to/file.txt > /dev/null

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)