Regexp: exclude a word or a phrase

S

Shuaib Zahda

Dear all

I am trying to exclude certain text from whole text using regular
expression but the i cannot get it working. I am using this to get the
text between the matches and not the match itself

for example, I have to process output of SVN DIFF and look through it

Index: filename1
==============
text
text
text
text
text
text
Index: filename2
==============
text
text
text
text
Index: filename3
==============
text
text

I want to count how many changed lines in each file, I am thinking of
getting the text between the lines of ========= which actually my target

i tried to use /[^=]+/ and it does not work because it will exclude
statements with equal signs as well which is not my aim

any idea

thanks
 
M

Marcelo

i tried to use /[^=3D]+/ and it does =C2=A0not work because it will
exclude statements with equal signs as well which is not my aim

I don't think I understand your intent, but in order to match
lines other than ones composed solely of =3D, try /^[^=3D]+$/

To match a location that does not contain a specific string, you
can try:

/(?!foo)/

this regular expression will match a location that does not
contain the sequence "foo". Beware! Note that I'm writing
"location", not "string". This matches:

"foo" =3D~ /(?!foo)/ )/ # anything not followed by foo, match

This also matches:

"foobar" =3D~ /(?!bar)/ # anything not followed by bar, match

You have to anchor it somehow:

"foobar" =3D~ /foo(?!bar)/ # "foo" not followed by "bar", no match

Marcelo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top