gettingstarted
[Top] [All Lists]

Re: Searching for Strings Within Strings

To: Getting Started <gettingstarted at lists dot realsoftware dot com>
Subject: Re: Searching for Strings Within Strings
From: Phil M <phil at mobleybros dot com>
Date: Sat, 28 Jan 2006 12:37:35 -0800
Delivered-to: gettingstarted at lists dot realsoftware dot com
References: <F0DC33DC-20D5-4438-9240-B2F76DEAE4D7 at pcisys dot net> <A7ED26FA-A4B9-42C6-8C1A-C41BCDAEC4DD at mobleybros dot com>
On Jan 28, 2006, at 12:17 PM, Phil M wrote:

What call is used to search for a string within a string?

I've poured over the Language Reference and seem to have missed it using Find and Match as search criteria.

InStr or InStrB (depending if you want to look for characters or bytes).

There is also RegEx, which allows you to search for strings based on patterns.

For example if you wanted to find a specific telephone number "800-491-5941" you would use InStr. But if you wanted to find all telephone numbers regardless of the number values you would use a RegEx pattern something like this:

    "\d\d\d[-]\d\d\d[-]\d\d\d\d"

Another example of RegEx is if you wanted to find "apple" but exclude words that have apple in them like "pineapple" and "snapple". Then you would use a search pattern like this:

    "\bapple\b"    // \b is a word boundary

RegEx is much more flexible than InStr, but it can also be a lot slower.

_______________________________________________
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>