@Chubler_XL
billion thanks for prompt response , in fact I have no "perl" background so if you can do me a favor and answer my below inquires it would be highly appreciated:
Could you please tell me where can I learn such regular expressions , any link or any book should go though ?
What is the equivalent regex for :
(?=.*dstcountry=("[^"]+"|\S+)) and (?=.*dstcountry="([^"]+)")
Many modern sed implementations support extended regular expressions (POSIX ERE) via the -E option . This is not a powerful as perl and does not support named capture groups, but should be sufficient for your requirement.
Using ERE with the sed -n option (to suppress automatic printing of pattern space) we can do:
sed -En 's/.*dstcountry=("[^"]+"|\S+).*/\1/p'
sed -En 's/.*dstcountry="([^"]+)".*/\1/p'
\1 in the replace part of the substitution is referring to the first capture group the same as $1 in perl.
Sorry I don't know of a good source to learn all this stuff, I just picked it up over the years of using these products. Perhaps try searching for "learning regex" or "regular expression examples" using your favorite search engine.
I did a quick search myself and came across this quite nice regex cheat sheet, it seems to cover a lot of features and is fairly easy to use Regex Cheat Sheet