regex - Regular expression, match anything but these strings -


within splunk have number of field extractions extracting values uri stems. have few match specific pattern, want regex matches these.

^/sitename/[^/]*/(?<a_request_type>((?!process)|(?!process)|(?!assets)|(?!assets))[^/]+) 

the regex above have far. expecting negative lookaheads prevent matching process, process, assets or assets. seems [^/]+ after these lookaheads can go ahead , match these strings anyway. resulting in regex overriding other regexes wrote accept these strings

what correct syntax me make regex match string, other specified in negative lookaheads?

thanks!

negative lookaheads do not consume of string being searched. when want multiple negative lookaheads, there no need separate them | (or). try this:

^/sitename/[^/]*/(?<a_request_type>((?![pp]rocess)(?![aa]ssets))[^/]+) 

note have combined lookaheads ([pp]rocess , [aa]ssets) make regular expression more concise.

live test.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -