How to express this in regex?

javascript, regex

Solution

You must escape the parenthesis :

/\s*void\s+main\s*\(\s*\)$/.test(kword_search)

But with the $ at the end, it won't accept the {, so you probably want

/\s*void\s+main\s*\(\s*\)\s*{$/.test(kword_search)

Problem

must be true ``` kword_search = "void main(){" kword_search = " void main(){" kword_search = "void main (){" kword_search = " void main ( ){" ``` what i've done so far: ``` /\s*void\s+main\s*(\s*)$/.test(kword_search) ``` The problem here kword_search = "void main" returns true with the condition i wrote. I want to do get inside a condition when the looping char is in the '{' position

Original source