I'm new in using regex, hope someone can help me. I'm using the regex below to grep a csv file for string that exactly has one pipe character (i.e. |)
grep "^([^\\|]+\\|){1}[^\\|]+$" myfile.csv
Unfortunately, the above yields no result when used with grep. Any ideas?
A sample csv file content is as below, where I expect the 2nd line to be found.
"foo"|"foo"|"foo"
"bar"|"bar"
Solutions to this question:
grep -E "^([^|]+\|){1}[^|]+$" myfile.csv
and
egrep "^[^|]+\|[^|]+$" myfile.csv