Wasim Wani
Wasim Wani

Reputation: 555

Finding a pattern of string at the start in a bigger string using regular expressions?

i just wanted to check through regular expressions if my string contained the word TSS at the start...e.g TSSProd or TSSRelease1...if TSS occurs anywhere in the middle or at the last it should return false...Please help as i have no knowledge of Regular expressions.Thanks in advance

Upvotes: 0

Views: 49

Answers (1)

Paul
Paul

Reputation: 141839

Use

var patt = /^TSS/
if(patt.test(mystring)){
    alert(mystring+' begins with TSS!');
}

patt.test(mystring) will return true if mystring begins with TSS and false otherwise.

Upvotes: 2

Related Questions