js regex with variable

Solutions on MaxInterview for js regex with variable by the best coders in the world

showing results for - "js regex with variable"
Frieda
03 Nov 2017
1// CREATE A REGEXP object
2var replace = "regex";
3var re = new RegExp(replace,"g");
4//then use
5"mystring".replace(re, "newstring")
Joshua
02 Feb 2018
1var pattern="cd"
2var repeats=3
3new RegExp(`${pattern}{${repeats}}`, "g") 
4
David
02 Jul 2020
1function alphabet(str) {
2  let alphabetStr = 'abcdefghijklmnopqrstuvwxyz';
3  let strRegEx =`[${str[0]}-${str[3]}]`;  //set regex with variables
4  let newRegEx = new RegExp(strRegEx, 'g'); //create new regex object
5  //regex object pattern is: RegExp(pattern, modifiers)
6  let charSetStr = alphabetStr.match(newRegEx);  
7  return charSetStr;
8}
9
10console.log(alphabet('abce'));
11//expected [ 'a', 'b', 'c', 'd', 'e' ]
queries leading to this page
regex with a variable jsjs build regex from variablejavascript regex in variablestring variable as regex jshow to add variable in replace javascriptjavascript variable inside regexpass variable to regex javascriptjs regex with varjs regex and varregular expression with variable javascriptjs variable in regexhow to use a variable in regex javascriptregex match js variable and its valuehow to use variable value in regex javascriptregex for variablesjavascript use variable in regexregex match js variable and valuehow to get and use variable regexjavascript replace regex variablehow to use a variable in a regular expression javascriptjavascript regex from string variablevariable in regex expput a variable in a regex jsstore regex in variable javascriptadd variable to javascript regexinclude variable in regex javascriptjavascript use variable regexadd variable in regex jsregex javascript get variablesget script variable in javascript via regexregex use variableregex string with variables javascriptcreate regex variable javascriptusing variable within regexhow to call a variable in regexregex 2fstring 2fi js use variablejs variable regexuse variables in regexhow to make regex out of variable javascript regex with variable in patternhwo to add a variable inside regex expression jsjs make a regex with a variablejs use variable inside regexjavascript how to use variable in regexvariable in regex jsspecify a value of regex from a variable in javascripthow to use variable in regex pattern javascriptadd variable to regexpvariable regex jshow to add variable in regular expression 2f 2f in javascriptnew regex with variableregex variableput variables in regexp patternregex get js variable and valuehow to regex variables jsnew regexp with variablereplace regex variable javascriptjavascript regexp with variables 24regex with variableadd variable to expresion regex javascripthow to use variable in rehexcan we use a variable inside regexjavascript varaibe in regexjavascript regex add variableuse variable inside regexpass regex expressin as variableassign regex to variable javascriptjs insert variable content into regexvaraible in regexregex pattern with variableuse variable in regex javasciprthow to use variable in a regexvariable in a regex jshow to add a variable in regex b javascriptjavascript regular expression with variablehow to write a variable in regex javascriptbuilding regex using variablesuse variable in regex jshow to put regex element in variable javascripthow to get a string variable in regular expressioncreate regular expression javascript using variablesuse variable in regex javastriptjavascript add variable to regexregexp with variables javascriptusing variables with regex javascriptjs create regex from variableadd variable to regex javascriptjavascript regex into variableuse variable value in regexp javascriptinsert variable into regex javascriptjavascript how to add variables in regexpretinsuse var in regezjavascript compose regexadd variable to regexinsert a variable into regex javascriptvariables in regex javascriptput variable in regex javascripthow to work with variables in regex javascripthow to create a regex using variable javascripthave variable value inside regexjs regex variableusing variables in javascript regexjs use variable in regexinsert variable in regex javascriptjs insert var in regexjs regex variable in patternhow to replace varialbe in expression jshow to create regex with variable javascritregex using variable javascriptpass variable in js regular expressionuse variable in regex pattern javascript execadd var in regex jsjavascript regular expression use value in variablehow do you insert a variable in regex jsregex var jsadd variable inside regex in javascripthow to use varialbles in regexregex javascript variablesjs regex and variregex with variable javascriptvariable regex javascriptvariable in javascript regexhow to write variables in regex javascripthow to add variable in regular expression javascriptregex of a variableregex in javascript variableuse variable in regular expression in jsnode js regex with variablehow to use variable in regex patternjs new regexp with variablejs insert variable in regexuse varaible in regex statment javascriptuse variable in regexp javascriptjs regex variable patternjavascript use va in regexregex use variable in javascripthow to make regex variable javascriptuse variable inside regex javascriptregex panrams javascrituse a variable in a regex javascriptadding variable to regular expressing javascripthow to give variable inside regex pattern javascriptnew regexp javascript variableusing variables in regexjavascript adding variable inside regexjavascript regex variablejava script variable regular expressionhow to write variable name in regex in javascript 3fvariable in a regexjavascript replace pattern variablejavascript variable in regexusing variable in regular expression javascriptjs regexp with variableshow to include variable in regexvariable in js regexpputting variables in regexjavascript regular expression use variablejs how to insert variable string in regexvariables in regexp javascriptcan you use variable in regex javascriptpass param to regex jsjavascript regex with variable withget variable javascritp regexjavascript regex include variablevariable regexjs insert variale in regexusing variables in regex jsjs put variable inside regexput a variable in regex jsjavascript regex with variablejavascript replace with variablejs variable inside regexjavascript regex using variablehow to search for a variable with javascript regular expressionusing variable in regexjavascript construct regex using variableusing a variable in a regex javascriptjavascript add variable into regexhow to put a variable in a regex javascriptjs regex using variableuse regex in javascript variablehow to include variable in regex in jsusing a variable in regex jsjs define a regex variablevariables inside regexuse variable in javascript regexusing variable in regex jsget variable in regular expression javascriptpass var to reg exuse variable in regex pattern javascriptregexp variable jspass a varaiable as a regexjs variable in regex replacecreate a regex expression from a variable javascriptcreate regex with variable strings javascriptvariable as regex jsregex 24 variablenodejs use variables in regexjs insert to regex variableregex use varaible javascriptjavascript variable in regex matchhow to insert variables into regex javascriptjavascript variable as regexjavascript regext variablecan i use variables inside regex javascriptreplace regex variable jsjavascript regex variablesregular expression pattern as a variable javascriptregex variable 2f 2fusing variable in js regexuse a variable inside a regex javascriptjavascript insert variable in regexhow to declare variable in regular expression javascriptjavascript add variable to regex patternregex for variable jshow to use variables in regex javascripthow to add variable in regexregular expression match variable literallyregex variable javascriptregexp with variable string in jsusing a variable with regexjs regex add variablecan you pass a variable to regexhow to define regex as variablejs var in regexregex with variablejavascript variable regexhow to put regex in string in jsregex from variable jsvariable in regex pattern javascriptpass variable to regrex literal notation javascriptpass a variable to a regexnode regex variable 22regexp 22create reg ex using variable jsjs regex use variableuse variable in regular expression javascripthow to form a regex in javascript variableuse variable in regex exp javascriptuse variable in regexpjavascript create regex from string variablework with regex with js variavleusing variables in regex javascripthow to pass variable to regex javascriptvariable in regex javascriptadd a variable in regex javascriptvariable regex patternhow to use variable inside regex expression in javascriptjs give a variable in regexregex variable value javascriptnode regular expression add variableregex javascript variablevariable in regular expression jsjavacript use variable in regex matchhow to pass a variable inside a regexjs set regex to variablehow to include variable inside regex typescriptjavascript regexp variableuse variable in a regexjavascript new regexp from variablejavascript regex from variablehow to put variable in regez javascripthow to insert variable into regex in javascriptjavascript variable in regex patternjs variable in regular expressionjavascript insert a variable in a regular expressionvariable in regexput js variable in regexjavascript arguments in regexcan i pass a variable to a regex javascriptadding variable in regexadd variable in regexargument in regex javascripthow to use variable in regex jsjavascript regex pattern with variablehow to add variable in regular expression js use var in regexpass variable to regular expression javascriptjs regexp variable in patternregex replace variable javascriptjavascript insert variable into regexset variable as regexjs regex from string variablejavascript how to make a regular expression variableregex nodejs add variablejs regex insert variablees6 regexp with variableregex variablesset string variable regex jswhy javascript regex in variableregex with javascript variableregexp variablepass variables in to regexjs regex with variableshow to use variables in regex jsinsert variable in regex pattern javascriptjs include variable in regexregex jwith variables javascriptjavascript using a variable in regexjavascript regex text in variablevariable inside regular expresionvariable in regular expression javascriptregex javascript with variable in patterjs use variable in regex patternjs regex how to put variable in patternregex with variable ses6 cant put variables inside regexhow i use a variable in regexjs regex from variableadd variable to regex jsusing javascript variables in regex expressionregex variable name javascriptregexp javascript with variable in patterndefine variable in regexregiular expression define variablevariable with regex javascriptjavascript variable name regexinsert variable in regular expression javascriptjs add variable to regexhow to use regex on a variablehow to use variable in regex javascriptnode regex with variablejs varibales inside regexesregex with variables javascriptregex variable is constant or let in jsput variable on regex jsjavascript variable in regular expressionjs variable in regex patternhow to insert string variable in regex javascripthow to pass a variable into regex javascriptregexp string with variable jsjavascript regex pass variablejs make regex with varableregex as variable javascriptjs put variable in regexregex variable in patternpass a variable into regexregex pattern variable javascriptvarible in regex jswhat is var regex 3dhow to write variable in regex javascriptjs var inside regexhow to variable pass in regex javascripthow do you use a variable in a regular expressionput variable in regexjs regex as variablejs reg variablevariables in regexhow declare variable in regex javascriptwrite a variable in javascript in regular expression replace javascript use varibalejavascript variable in regechow to add a variable to regexp in javascriptstring variable in regex jsregex js using variablehow to put variable in regex javascriptusing variables in regex pattern javascriptregex from variable javascriptuse a paramater in regex jsput variable number into regex javascriptput regex in stringvariable in regexphow to pass a variable in a regular expression javascripthow to pass a variable in as regexadd variable in regex javascirptregex for javascript variable name javascript regexp variablesjs regex with variable in patternvariable inside regex jshow to use variable in javascript regular expressionjavascript regexp constructor with variablemake regex with variableregex variable jsregexp with variable jshow to put a variable string in a regex javascriptpass variable into regex javascripttype variable in regex javascriptregex with parameter javascriptjs pass variable to regexturn variable into regex javascriptvar in regex jsjavascript regular expression variable in patternhow to insert a variable into replace jsregular expression as a variableadd variable in regex javascriptnode make regex from string variablereference variable in regexuse variable in regex javascripthow to put variable between regexjs regex as a variablehow to put a variable in regexpass variable in regex javascriptregex variable meaningput a variable in regexuse a variable in regexuse variables in regex javascriptregex in variable javascriptadd a variable in regex replacehow to assign regex to variable javascriptadd regex to var in jsuse regex with var jsuse vartible in regexhow to but a varivable string inside regexjavascript pass variable to regexhow to pass variable in regexpass dynamic regex value in new regexpjavascript use variable in regular expressionvariable inside regex javascripthow to put variable in regex javascript 2f 2fregex javascript use variablevariable inside a regexvariable in js regexjavascript variable regular expressionjs regex with variableregex from a variable jshow to use variable in regexhow to pass variable in regexp substring regex javascript using variablejavascript regex variable in patternhow to pass variable in regex javascripthjavascript regexp use variablevariable into regex javascriptjavascript regex match variablehow to create regex variable javascriptcreate regex with variable javascriptregex with variable in javascriptjs replace regex variaregex js variablejs variables in regex 2fvariable 2f in regular expression in javascriptpassing variable as regex javascriptadd variable regex jsjs regex in if to varhow to make a regex with variable javascriptuse parameters in regexregex use variable name javascriptregext variable javascirptregex javascript with variablejs save regex as variablevariables in regex jshow to insert variable in regexregex with variable jsuse a variable like regexjs regex to variablehow to use a string variable in a regual expression javascriptjs variable within regexpnew regex js with variableuse variable for regular expression javascriptusing a variable in regexjavascript variable in regexphow to put variable name in regex javascriptuse a variable in regex javascriptfunction regexvar 28 29js new regexp variableuse variable in regexjavascript use variable in regex replacenodejs add regexp on a variablejs variables inside regexjs regex with variable