Just now I was looking for a regex that will detect string not enclosed in double quotes. I got fabulous answer to that which worked in javascript. I am actually trying to run it using grep but it isn’t working. Can anyone help me why this regex isn’t working
Sample string : "quick" "brown" fox jumps "over" "the" lazy dog
I am trying to run : echo "quick" "brown" fox jumps "over" "the" lazy dog | grep -e '(?<![\S"])([^"\s]+)(?![\S"])'
It gives no output. How different are linux regexes from normal regexes. How can this be done?
Please help. Refer to this link: http://regexr.com?31eg3 for the same
Two things, first you need to quote the whole string to echo, or the shell strips the double quotes. Then you are using perl-style regular expressions, so you need to tell grep to use them for matching with the
-Poption.Here I added
-o, so it is clear what was matched.