javascript - pegjs regular expression match words up until a word from a collection of words is found -


i using pegjs parser generator project , having difficulty creating grammar should match words until collection of words should not match. example in string "the door yellow" want able match words until is, tell pegjs parser start parsing word is. collection of words want parser break on "is" "has" , "of".

current grammar rule follows:

subject "sub" =  s:[a-za-z ]+ { return s.join("").trim()} 

how can create ahead stops parser including collection on words?

(!of|is|has) 

this work

.+(?=\s+(of|is|has)) 

it matches 1 or more of characters (except line breaks) until encounters either 'of', 'is', or 'has' (via positive lookahead) white space before them.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -