> > Why not use something like:
>
[quoted text clipped - 14 lines]
>
> Chris
I don't know of a way to define a start point for regex, expect if you
pass a substring of the phrase into the function - but then you'll
need to adjust the index to find the original position of the string.
You will also take a minor performance hit for creating the substring
(this won't matter unless you do it millions of times back to back).
Besides, regex runs extremely fast, so you probably won't notice the
difference between changing the start points.
Also, you may look at downloading expresso, it's a great tool for
building/evaluating regular expressions, and it is definitely helping
me out with my current project.
http://www.ultrapico.com/Expresso.htm
Thanks,
Seth Rowe
Chris Mahoney - 18 Apr 2007 23:01 GMT
> I don't know of a way to define a start point for regex, expect if you
> pass a substring of the phrase into the function - but then you'll
[quoted text clipped - 3 lines]
> Besides, regex runs extremely fast, so you probably won't notice the
> difference between changing the start points.
It's not the cleanest code ever, but I've written a new InStr that
accepts a Regex and can take indices :)
Function RegexInStr(ByVal Start As Integer, ByVal String1 As String,
ByVal String2 As String) As Integer
If String1.Length < Start Then Return 0
Dim intCharsToRemove As Integer = Start - 1
Dim strToTest As String = Strings.Right(String1, String1.Length -
intCharsToRemove)
Dim intIndex As Integer =
System.Text.RegularExpressions.Regex.Match(strToTest, String2).Index +
1
If intIndex = 1 And Strings.Left(strToTest, String2.Length) <>
String2 Then Return 0
Return intIndex + intCharsToRemove
End Function
My problem is now solved, and I thought I'd just post my code here in
case someone else runs into a similar problem.
Thanks for all your help!
Chris