Regular expressions

Brian Yennie briany at qldlearning.com
Thu Feb 5 15:53:35 EST 2009


Hi Craig,

Read it as "one 'Z' followed by zero or more 'A' followed by one 'B'".  
Thus the Z and B are required with any number of A in between  
(including zero). So it would match:

ZB
ZAB
ZAAB
ZAAAB

And so on.

In short, a single letter matches just that - a single letter. The *  
and + operators change the meaning to "zero or more" and "one or more"  
respectively. If you want the operator to apply to an entire  
expression, you need to group the expression in parentheses (or  
brackets, but that has another meaning).

I think you may have a typo in your question, since both of your  
examples have the same expression - but hopefully that helps.

> OK, got the list of these, and I understand all of them but two:
>
> 1- The asterisk matches zero or more occurrences of the preceding  
> character
> or pattern...
>
> So why does   "ZA*B" match "ZB", but does not match "AB""
>
> And the "+" matches one or more occurrences of the preceding  
> character or
> pattern
>
> So why does   "ZA*B" match "AB", but does not match "ZB"?
>
> I know it will be obvious in about 20 minutes, when I get the first
> repsonses.
>
> Powerful tools, though.
>
> Craig Newma



More information about the use-livecode mailing list