Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Fri, 27 Jun 2008 12:21:12 -0400, Mike
wrote: <snip Thx. I suspect the "meat" is in your regex scrips and/or your data, and not in what you posted. It may be in how you define your "small range of the following characters". It might also have to do with typos in your data -- there are several typos in what you've posted and, if these were copied from your data, the regex's probably would not behave as you expect. --ron ron Yeah, it's jut a quick snippet w/o the benefit of copy & paste (at 4 am). My work doesn't allow any kind of i/o. Allow me to make some sense. I didn't see (b4 posting) that there's a whole lot of regex activity in here! Let's say my target string is the following: "Frodo went over to Frodo's house and ate Frodo's food." What I'm searching for is every instance of 'Frodo', with a chunk of following text to give it some context. I'm actually looking for instances of a common term whose meaning can be determined by the following words. By displaying a sort of phrase the user can quickly see if the term is being used in the context that interests him. The search pattern is "Frodo.{0,16}". The resultant match values are : "Frodo went over to Fr" and "Frodo's house and ate" and "Frodo's food." It works fine with an example like this. However if I have a source str where the patterns are close together, I 'lose' the subsequent matches. For example, "Frodo wore Frodo's pants." will result in a match collection size of 2, with the first value "Frodo wore Frodo's pa", and no second value. The only solution I can see is to get the positions of the matches, and extract the text using substring. Well, the following regex, with the appropriate options set, will return all strings that start with Frodo and end either with the next Frodo or with the end of a line: Frodo.*?(?=Frodo|$) Here are the options I set: ..Global = True ..IgnoreCase = True ..MultiLine = True ..Pattern = "Frodo.*?(?=Frodo|$)" --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
RegExp | Excel Programming | |||
RegExp information | Excel Programming | |||
RegExp - String in VBA | Excel Programming | |||
Declare RegExp from Vbscript.dll | Excel Programming | |||
How do you look for two distinct patterns (RegExp) | Excel Programming |