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
I don't think I understand your intent, but in order to match
lines other than ones composed solely of =, try /^[^=]+$/
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" =~ /(?!foo)/ )/ # anything not followed by foo, match
This also matches:
"foobar" =~ /(?!bar)/ # anything not followed by bar, match
You have to anchor it somehow:
"foobar" =~ /foo(?!bar)/ # "foo" not followed by "bar", no match
Marcelo
···
On Tue, Apr 20, 2010 at 07:29, Shuaib Zahda <shuaib.zahda@gmail.com> wrote:
i tried to use /[^=]+/ and it does not work because it will
exclude statements with equal signs as well which is not my aim
"Shuaib Zahda" <shuaib.zahda@gmail.com> wrote in message
news:1d6e0a96aa6e168091bdabb7c3fbf359@ruby-forum.com...
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