Jump to content

pattern matching jQuery - REGEX


glenelkins

Recommended Posts

Hi

 

Is there a way to do a pettern match in jQuery? I have tried the following and doesnt work!

 

var pattern = '/[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/';
var string = '[email protected]';

if ( string.match ( pattern ) ) {

   //do something good

} else {

    //do something bad

}

Link to comment
https://forums.phpfreaks.com/topic/166034-pattern-matching-jquery-regex/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.