On Jan 29, 2007 8:59 PM, Guyren Howe wrote:
> <http://realsoftware.com/feedback/viewreport.php?reportid=udsbvegd>
>
> In 2K7r1, the first regex match against a string updates the
> SearchStartPosition, but subsequent searches only ever find the first
> match, and SearchStartPosition isn't updated.

This is *not* correct.
The problem is that you're not using RegEx.Search correctly ;-)

In this example, that you posted with the report,
  Dim r As New RegEx
  Dim m As RegExMatch

  Dim searchString As String = "abcdabce"

  r.SearchPattern = "abc(d|e)"
  m = r.Search(searchString)
  Break //Here, r.SearchStartPosition = 4, as it should be
  m = r.Search(searchString)
  Break //Here, r.SearchStartPosition = 4, and we still find the first pattern

the second time you use Search you cannot use the "searchString" for the
TargetString parameter and you should only use:
 m = r.Search() // without the TargetString
and then you'll get 8 for the r.SearchStartPosition.

>From the LR:
RegEx.Search [TargetString], [SearchStartPosition]
"Both parameters are optional; if TargetString is omitted, it assumes the
previous TargetString, so you will want to pass a TargetString the first time
you call Search. If you call Search with a TargetString and omit
SearchStartPosition, zero is assumed. If you call Search with no parameters
after initially passing a TargetString, it assumes the previous TargetString and
will begin the search where it left off in the previous call. This is the
easiest way to find the next occurrence of SearchPattern in TargetString."

Tested on 2005r4 and 2007r1 on Windows.

HTH
Carlos

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to