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".
to answer new question:
to names not following \, may use /([^\\]|^)(\w+)/g (and use second capturing group third element in returned array).
Comments
Post a Comment