python - Regex for word exclusion -


i'm trying write regex match first , third words in string:

term1 , term2 

my first attempt [^(\s|(and))]+, fails because

term1 anbd term2 

gives me these 3 matches: ['term1','b','term2'] whereas want return ['term1','anbd','term2']

match first , third words: (\s+)\s+\s+\s+(\s+)

edit: if mean 'match words except word "and"' then: \b(?!and\b)\s+\b


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -