From: Mark Wilson Date: 2002-12-19T15:35:02+09:00 Subject: Re: How to include some text and exclude other in one regular expression? 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 >