Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

regex for anything but quoted strings site:stackoverflow.com

var rgx = /(B(".+?")B|B('.+?')B|B(`.+?`)B)/g;

var str = `"Lorem ipsum dolor sit amet", consectetur adipisicing elit, "'sed do eiusmod tempor,'" incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, `quis nostrud` exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. `Duis aute irure dolor` in "reprehenderit in voluptate" velit esse cillum 'dolore eu fugiat nulla' pariatur. `;

var sub = ``;

var res = str.replace(rgx, sub);

console.log(res);
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #regex #quoted #strings
ADD COMMENT
Topic
Name
7+3 =