Negative Lookahead With ANSI Escape Code in Capture Group

Viewed 25

Basically trying to capture a group named "text" which should include any chars before \x1B.

Using a negative lookahead inside the capture group (shown below) does not seem to work.

const line =  `● lorem ipsem \x1B]8;;https://example.com/,\x07Example\x1B]8;;\x07 & \x1B]8;;https://google.com,\x07google\x1B]8;;\x07`
                    
const re = /\x07(?<text>(?!:\x1b).*)\x1b\]8;;\x07/g
                
re.exec(line)
                
  //..
  //.. 
  // groups: {
  //      text:  'Example\x1B]8;;\x07 & \x1B]8;;https://google.com,\x07google'  /*bad... should be 'Example'*/ 
0 Answers
Related