matching regexp

Hi,

maybe it is stupid question, but is it possible to match expression like this ? :

... // ... ( there is "//" somewhere on the line and on the end of the line there ISN'T "*/" )

I've tried something like : (in SED)

sed 's/\/\/[^*/]'

but I need "*/" not to be on the end of the line ... I know there is a special char for this $, but how to use it there...

Thanks for any answers...

Something like this ?

$
$
$ cat f6
line 1 - the quick brown fox jumps over the lazy dog
line 2 - the quick brown // fox jumps over the lazy dog
line 3 - the quick brown // fox jumps over the lazy dog */
line 4 - the quick//brown fox jumps over the lazy dog
line 5 - the quick//brown fox jumps over the lazy dog*/
line 6 - the quick // brown fox */ jumps over the lazy dog
$
$
$ sed -n '/\/\/.*[^*\/]$/p' f6
line 2 - the quick brown // fox jumps over the lazy dog
line 4 - the quick//brown fox jumps over the lazy dog
line 6 - the quick // brown fox */ jumps over the lazy dog
$
$ # or using Perl
$ perl -lne '/\/\/.*[^*\/]$/ and print' f6
line 2 - the quick brown // fox jumps over the lazy dog
line 4 - the quick//brown fox jumps over the lazy dog
line 6 - the quick // brown fox */ jumps over the lazy dog
$
$

tyler_durden

1 Like

thanks a lot it is exactly what I wanted to know... :b: but I am little bit surprised that I got answer right from you, because yesterday I saw Fight club and today you are here, answering me ... so I am little bit scared that I wrote that answer by myself :wink: .