I need regex to match a condition like below:
if ev or pp is in the begining of string and has any number after that,then it should match
For example:
if string is ev100 then it will satisify the condition so it should print ev100.
if string is pp44 then print pp44.
if string is ep39 then it will not satisfy the condition. Hence it should not be printed
You may use match here with the regex pattern ^(?:ev|pp)\d+:
var inputs = ["ev100", "pp44", "ep39"];
inputs.forEach(x => x.match(/^(?:ev|pp)\d+/) ? console.log(x) : "");