testing on case

Dar Scott dsc at swcp.com
Thu Dec 9 14:53:14 EST 2004


On Dec 9, 2004, at 11:46 AM, Hershel Fisch wrote:

>> if matchText( param(x), "^[A-Z]") then put xxx else put x
> I don't get it

The expression matchText( z, "^[A-Z]") will return true if (and only 
when) the first character is an ASCII capital letter.  The "^" matches 
the beginning of the string (or line).  A more exact pattern is "\A"; I 
used "^" because it might be more familiar.  The immediately following 
pattern [A-Z] matches any letter in the range A-Z in ASCII.  It must 
match right after the previous pattern match, that is, the beginning.  
There is no pattern matching for the end of the string so the rest of 
the string z does not matter.  That is, matchText() returns true if the 
pattern occurs anywhere in the string, not just if it matches the whole 
string.  (Use \A and \z to match the ends to make a pattern match the 
whole string.)

You can find more info on regular expressions here:

    http://www.perldoc.com/perl5.8.0/pod/perlre.html

But you have to skip over all the perl specific parts.

You can find more specific information on exact usage of the actual 
library used in Revolution and (I assume) Dreamcard here:

    http://www.pcre.org/pcre.txt

But you have to skip over all the building and calling parts.  Skip 
down to PCRE REGULAR EXPRESSION DETAILS.  I think you need to skip over 
the unicode and UTF-8 paragraphs, too, for now.

Dar

****************************************
     Dar Scott Consulting
     http://www.swcp.com/dsc/
     Programming Services
****************************************



More information about the use-livecode mailing list