==================
For my sins - I have the following expressions that I need to compare a string against in javascript.


[F|K]([0-9]{4}) = F1234 or K1234

try ^(F|K)[0-9]{4}$


[CC]([0-9]{4}) = CC1234

try ^CC[0-9]{4}$


[F]([0-9]{4})[-]([0-9]{2}) = F1234-12

try ^F[0-9]{4}\-[0-9]{2}$


Are these valid in JS? Do I just now assign them to a variable and use them in the brackets of mystring.match() ?

The match() method for strings accepts either a RegExp object or a string that can be used in the RexExp new constructor to create a new RexExp object, e.g. mystring.match("^(F|K)[0-9]{4}$")


It returns an array containing the matches, you can check if the return value is null to determine whether a match is found


Mark


-- These lists are syncronised with the CFDeveloper forum at http://forum.cfdeveloper.co.uk/ Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

CFDeveloper Sponsors and contributors:-
*Hosting and support provided by CFMXhosting.co.uk* :: *ActivePDF provided by 
activepdf.com*
     *Forums provided by fusetalk.com* :: *ProWorkFlow provided by proworkflow.com*
          *Tutorials provided by helmguru.com* :: *Lists hosted by gradwell.com*

To unsubscribe, e-mail: [EMAIL PROTECTED]



Reply via email to