Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Fri, 27 Jun 2008 06:30:33 -0400, Mike
wrote: Hi all. I've found a litle set of scripts to use regex in Excel, but there's a snafu. Here's the meat: Set allMatches = REObject.Execute(StringToSearch) ReDim result( 0 to allMatches.Count - 1) For i = 0 to allMatches.Count - 1 result( i ) = allmatches( i ) .Value next i and so on,,, Typically I want to find a substring consisting of the first match plus a small range of the following chararcters(any characters), the second match and a range after that, etc. Something like this: vbscript( "the battlestar pegasus was run by a nutcase, and the battestar galactic was a rustbucket", "battlestar.{0,30}") What I want to get is "battletstar pegasus was run by" and battlestar galatica was a rustbucket", or similar. The problem I run into is when the tokens are close together. Then I somehow lose the second match: vbscript( "the battlestar p and the battestar g are filled with cylons", "battlestar.{0,16}") In this case I get "battlestar p and", and then nothing for the second match. It's as if the second match causes the first match to truncate somehow. Does the object make a fixed range for each match or something? 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 |
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 |