From: GianFranco Bozzetti Date: 2010-04-20T23:30:05+09:00 Subject: Re: Regexp: exclude a word or a phrase "Shuaib Zahda" 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 > > any idea > > thanks > -- > Posted via http://www.ruby-forum.com/. > The regexp /^\=+$/ will match a whole line of '=' as in: re = /^\=+$/ count = 0 section = 1 DATA.each_line do |row| if(re =~ row) then printf("section %d has %d records\n", section, count) count = 0 section +=1 else count +=1 end # if end # while exit(0) __END__ text1- text2= text3- ========== text4 text5 ========== Hth gfb