realbasic-nug
[Top] [All Lists]

Re: RegEx searching

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: RegEx searching
From: "Kiam" <kiam at avpnet dot org>
Date: Fri, 29 Dec 2006 23:02:29 +0100
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Organization: AVPnet
References: <62959319-CCE1-454D-B9CA-EC300FFEDE7D at redpro dot se>
----- Original Message -----
From: "Peter Karlsson" <lists at redpro dot se>
To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
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>


<Prev in Thread] Current Thread [Next in Thread>