How to convert string to regex pattern output?
For example,
var num ='1234567890' number is fixed 10 digits regex pattern changes.
*1* ^[0-9]{3}-[0-9]{3}-[0-9]{4}( x[0-9]{1,5})?$
2.^([0-9]{3}) [0-9]{3}-[0-9]{4}$ 3.... so on up to n.
Output should be based on the pattern given for Pattern 1 output 123-456-7890
Pattern 2 output (123) 456-7890 . . pattern n output .... is it possible to give regex pattern and string get excepted output
var result = num.replace(pattern,inputstring)