Home > Net >  How to pass special characters dynamically in maskRe attribute of Extjs?
How to pass special characters dynamically in maskRe attribute of Extjs?

Time:07-10

As of now, I am trying to achieve successfully with static values for eg.,

maskRe: /^[A-Za-z0-9 $%] $/  

but I wanted to pass $% dynamically with some variable instead of hardcoding.

CodePudding user response:

You can use RegExp class to create a RegExp object from a string. The string can be as static as a formatted.

let dynamicValue = "$%";
let regex = new RegExp(`^[A-Za-z0-9 ${dynamicValue}] $`);

console.log(regex);

  • Related