I may be thinking this about the wrong way.
The first three (...)
's are generated and could be any number. I only want to catch these first set of items and allow the user to use ()
inside of their custom string.
(374003) (C6-96738) (WR183186) R1|SALOON|DEFECTIVE|WiFiInfotainment|Hardware detects WIFI but unable to log in on the (JAMIE HUTBER) internet.:
/\(([^)]+)\)/g
["(374003)", "(C6-96738)", "(WR183186)", "(JAMIE HUTBER)"]
["(374003)", "(C6-96738)", "(WR183186)"]
You can use two ways to do that:
\\(([^ )]+)\\)
( https://regex101.com/r/ZPdq35/1/ ) Using the sticky option /y
you can then use regEx's ability to find all occurrences..
This will then work, if there is not a space in JAMIE HUNTER
, etc..
eg.
const re = /\\s*\\(([^)]+)\\)/y; const str = "(374003) (C6-96738) (WR183186) R1|SALOON|DEFECTIVE|WiFiInfotainment|Hardware detects WIFI but unable to log in on the (JAMIE HUTBER) internet.:"; let m = re.exec(str); while (m) { console.log(m[1]); m = re.exec(str); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.