From: Usano Date: 2003-01-22T06:38:22+09:00 Subject: Re: How to include some text and exclude other in one regular expression? Thank you for the help (everyone). The problem domain is binary files from Usenet. There is no one standard that all adhere to such as the delimiter as you suggested in your response, Mark. Also, there may be varied text before and after this sequence, so the other two suggestions won't work. I suppose I will have to face the fact that what I cannot exclude unwanted possibilities all in the same regex. Thanks, - usano On Thu, 19 Dec 2002 15:35:02 +0900, Mark Wilson wrote: >I think this problem can only be solved by knowing the problem domain. >In particular, one would need to know if "file 1 of 2" and "1 of 2" had >a common delimiter in front of them that is distinguishable from the >delimiter in front of "day 1 of 2" or "page 1 of 2", etc. For example, >an "(" might be such a delimiter in some text collections. >Alternatively, one could negate occurrences of "file 1 or 2" and >inspect the resulting lines that contain "1 of 2" for words in front of >"1 of 2" (sorting and taking the unique instances would help here) and >then expressly negate those. > >On Wednesday, December 18, 2002, at 11:34 PM, Usano wrote: > >> I would like to match "file 1 of 2" or "1 of 2", but not "day 1 of 2". >> >> I can match "file 1 of 2" with... >> >> /(file)? *\d+ *of *\d+/ >> >> I wonder if (in the same regex), I can prevent a match to "day 1 of >> 2"? The above expression will match this by just ignoring the word >> "day". >> >> Can this be done? >> >> Thank you, >> - Usano >> >