OT: Some help with Regular Expressions

Monte Goulding monte at sweattechnologies.com
Thu Nov 4 17:40:14 EDT 2010


Just a small correction to your regular expression Jeff to make it case insensitive as it ignores the caseInsensitive global property and also assuming that Mathias doesn't want to match chunks of longer strings I've added the ^ & $:

(?i)^([a-z0-9]{2})\.([a-z0-9]{5})\.([a-z0-9]{3})$

Cheers

Monte

On 05/11/2010, at 6:57 AM, Jeff Massung wrote:

> It would be good to know where the numbers and letters are if that's
> possible. But this will get you going:
> 
> local tXX
> local tYYYYY
> local tZZZ
> 
> ## just a simple unit test
> get "A1.B35AZ.001"
> 
> ## do the match
> if matchText(it, "([a-z0-9]{2})\.([a-z0-9]{5})\.([a-z0-9]{3})", tXX, tYYYYY,
> tZZZ) is true then
>   put tXX & cr & tYYYYY & tZZZ
> end if
> 
> If you need it to be more specialized (eg, the format is really:
> A#.A##AA.### where A=alpha and #=number) then let me know and I can get a
> better matching pattern for you.
> 
> Jeff M.
> 
> On Thu, Nov 4, 2010 at 1:48 PM, Matthias Rebbe <runrev260805 at m-r-d.de>wrote:
> 
>> Dear all,
>> 
>> i have to check for an value in the format  XX.YYYYY.ZZZ (e.g.
>> A1.B35AZ.001 or a1.b35az.001)
>> I have to check if the value is in the right format. I know i can do that
>> with matchtext and a regular expression, but
>> i do not know enough to get the regular expression to work.
>> 
>> Is there anyone who might be able to help?




More information about the use-livecode mailing list