----- Original Message -----
From: "Peter Karlsson" <[EMAIL PROTECTED]>
To: "REALbasic NUG" <[email protected]>
Sent: Friday, December 29, 2006 10:27 PM
Subject: RegEx searching

Hi,
Is there a way to get RegEx to give the character position of a result as instr do? I've played with SubExpressionStartB but it only gives byte positions and that's not enough to select a word in an editfield if there's umlauts.


You could combinate a call to SubExpressionString() (class RegExMatch) with a call to InStr(), which accepts an optional parameter to say from which position to start the search.

question 2:
is
rx.SearchPattern = "(\W)" + search + "(\W)"
the best pattern to find a word?


I would rather use "rx.SearchPattern = search", which does the same thing without to be time wasting. If you want then to be sure to match a complete word, then I would use "rx.SearchPattern = '\s' + search + '\s'", or a better "rx.SearchPattern = '\b' + search + '\b'".
--
~Kiam


_______________________________________________
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