Javascript regex: ignore every letter after backslash -


i want retrieve free variables in lambda expression. example

\z.\x.(xy) 

, "\" stand lambda symbol: through regex, need letters don't follow backslash. in example, free variables

{y} 

since "y" variable not bounded "\". how that? in advance.

you can use /\\(\w+)/g , iterate exec :

var r = /\\(\w+)/g, m,     s = "\\z.\\x.(xy)"; while (m = r.exec(s)) console.log(m[1]); 

it logs "z" "x".

demonstration


to answer new question:

to names not following \, may use /([^\\]|^)(\w+)/g (and use second capturing group third element in returned array).

demonstration


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -