Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js string to regex

const regex = new RegExp('https://w*.w*.*', 'g');
Comment

string to regex javascript

function stringToRegex(s, m) {
  return (m = s.match(/^([/~@;%#'])(.*?)1([gimsuy]*)$/)) ? new RegExp(m[2], m[3].split('').filter((i, p, s) => s.indexOf(i) === p).join('')) : new RegExp(s);
}

console.log(stringToRegex('/(foo)?/bar/i'));
console.log(stringToRegex('#(foo)?/bar##gi')); //Custom delimiters
console.log(stringToRegex('#(foo)?/bar##gig')); //Duplicate flags are filtered out
console.log(stringToRegex('/(foo)?/bar')); // Treated as string
console.log(stringToRegex('gig')); // Treated as string
 Run code snippetHide results
Comment

PREVIOUS NEXT
Code Example
Javascript :: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ionic build 
Javascript :: custom hook for unique items in react 
Javascript :: array object sort by date 
Javascript :: how to get the number of days in a month in javascript 
Javascript :: vue send event plus variable 
Javascript :: express serve node module 
Javascript :: javascript map api key insert 
Javascript :: javascript to typescript converter online 
Javascript :: html how to get js 
Javascript :: js window selection get new line 
Javascript :: powershell json check if property exists 
Javascript :: how to pass information to a type=hidden from a function in javascript 
Javascript :: how to reset count in react 
Javascript :: NetSuite Add Line Item to a Sales Order in afterSubmit 
Javascript :: k6 control a live k6 test 
Javascript :: jaavascript loop array 
Javascript :: automatic expiry for a document in mongodb 
Javascript :: eslint resolve error unable to lead resolver 
Javascript :: wrap three three set div in a single div 
Javascript :: set body angle matter.js 
Javascript :: /home/raj/Desktop/webProjects/node-shop-api/node_modules/whatwg-url/dist/encoding.js:2 const utf8Encoder = new TextEncoder(); ^ ReferenceError: TextEncoder is not defined 
Javascript :: node.js version change to 6.14.15 windows 
Javascript :: javascript check if input is empty 
Javascript :: Nested comparison operator in Javascript 
Javascript :: javascript random to abs 
Javascript :: stop React Ant Design Upload component from posting files automatically 
Javascript :: Search products by startsWith in javascript 
Javascript :: access object data 
Javascript :: Make a ReactNative component take the height and width of the current window 
Javascript :: jacascript loop array 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =