DEV Community

Varun Hegde
Varun Hegde

Posted on

I am trying to match this text with regexp but getting error

string : ----------------Page (0) Break----------------
(it can have any number inside parenthesis)

pattern : /?<=-{16}Page ()(\d+)(?=) Break-{16})/g

usage :

if(line.search( /?<=-{16}Page ()(\d+)(?=) Break-{16})/g )!=-1)
{
console.log(line);
}

error : SyntaxError: Invalid regular expression: /?<=-{16}Page ()(\d+)(?=) Break-{16})/: Nothing to repeat

Any help would be appreciated.
Thank You

Top comments (2)

Collapse
 
crimsonmed profile image
Médéric Burlet

Please read the markdown guide to format your post properly and make it readable thanks!

Collapse
 
srknhcgl profile image
srknhcgl

-{16}Page ((\d+)) Break-{16}
if you just want to extract number inside parenthesis, use (\d+)
please check on a tool like regexr.com/