Tuesday, December 4, 2012

How to know that a string starts/ends with a specific string in jQuery

One option is to use regular expressions:
if (str.match("^Hello")) {
   // ...
}

if (str.match("World$")) {
   // ...
}

No comments:

Post a Comment