Regex - pattern capture everything except for pattern [.net] -


i capture to, not including particular patter. actual problem has parsing out information html, distilling problem down example to, hopefully, clarify question.

source

xaxbxcabcabc 

desired match

xaxbxc 

if use lookahead expression capture first occurrence

.*(?=abc) => xaxbxcabc 

i along lines of negated character class, negated pattern.

.*[^abc] //where abc pattern instead of list giving a, b or c 

i using http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx testing

if anchor regex you'll solve problem (+ use of lazy quantifier):

"^.*?(?=abc)" 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -