Wildcard char for searching?

Ken Ray kray at sonsothunder.com
Fri Nov 1 02:30:01 EST 2002


Mark,

The best way is to use regular expressions (see the "matchText" and
"matchChunk" entries). So for example to verify that a string exists
starting with "a" and ending with "e" within another string, you'd do this:

on mouseUp
  put fld 1 into textToSearch
  put matchText(textToSearch,"a[^ ]*?e") into stringIsThere
  if stringIsThere then
    answer "It's in the field."
  else
    answer "It's not in the field."
  end if
end mouseUp

Note that the character after the ^ in the above code is a space. It says
"look for an 'a', followed by zero or more characters that are not spaces,
and ending with 'e'".

If you want to retrieve the text to examine the match, you can do this:

on mouseUp
  local theWord
  put fld 1 into textToSearch
  put matchText(textToSearch,"(a[^ ]*?e)", theWord) into stringIsThere
  if stringIsThere then
    answer "It's in the field, and it's: " & theWord
  else
    answer "It's not in the field."
  end if
end mouseUp

Note the parentheses around the regulare expression, which says to "extract
it", and the defining a local variable (theWord) to hold the extracted
result.

BTW: Regular expression support is good in Rev 1.1.1, but will be great in
Rev 2 because of full Perl-compatible regular expression support.

Hope this helps,

Ken Ray
Sons of Thunder Software
Email: kray at sonsothunder.com
Web Site: http://www.sonsothunder.com/


----- Original Message -----
From: "Mark Swindell" <mdswindell at charter.net>
To: <use-revolution at lists.runrev.com>
Sent: Friday, November 01, 2002 1:07 AM
Subject: Wildcard char for searching?


> Is it possible in Revolution to search for a string using a wildcard
> character, such as:
>
> Find "a*e"
>
> where the asterisk would represent any character between the letters "a"
and
> "e?"
>
> If not, what might be the best way to accomplish this?
>
> Thanks,
>
> Mark
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list