DEV Community

loading...

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

varuntumbe profile image Varun Hegde ・1 min read

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

Discussion

pic
Editor guide
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/