Write a javascript function to match string starting with.AB or AB
The string should either start with .AB or AB followed by anycharacters.
i am getting confused how to form regular expression and techand match using function . the string should match with the firsttwo characters AB or first three characters .AB then only alertstatement(“string is correct”) otherwise alert statement (“Stringis not correct”)
input1 : .AB2e234324
output: string is correct
input2 : AB44r4r44r
output: string is correct
input3 : ABdsfdsfds
output: string is correct
input4 : AfB.dsf3
output string is incorrect
=======================
The language is Javascript.
Expert Answer
Answer to Write a javascript function to match string starting with .AB or AB The string should either start with .AB or AB follow…