Answers for "regex match everything except"

5

regex match everything except

let reg = /[^charachter_to_not_match]*/
// Example
let str = '<<1,2,3>, <4,5,6>, <7,8,9>>'
//match everything but '>'
reg = /[^>]+/g // Array(3) ["<<1,2,3", ", <4,5,6", ", <7,8,9"]
//match everything but '<' and '>'
reg = /[^<>]+/g // Array(5) ["1,2,3", ", ", "4,5,6", ", ", ...]
//match anything but '<', '>', ',' and '\s' (\s=any whitespace)
reg = /[^<>,\s]+/g // Array (9) ["1", "2", ..., "9"]
Posted by: Guest on April-06-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language