How can I keep a general qualifier pattern from matching unwanted text?
You can prevent a pattern from always matching like this:
^(?!exc)(?P<0>.+)\sAxle$
This says, don’t match if the text starts with “Exc”. This would be useful if you need to match two different qualifiers such as:
<param type="name"/> Axle
Exc <param type="name"/> Axle
Without the “(?!exc)” portion of the pattern, the “.+” would match all characters up to “Axle” and so include “Exc.” in the name param.
^Exc (?P<0>\w+) Rear Axle$ => Qdb 3089
^Exc (?P<0>\d+) lb Rear Axle$ => Qdb 18062
Example:
Exc 11000lb Rear Axle
The solution is to tell the first pattern not to match if it finds “lb” before ” Rear Axle”
^Exc (?P<0>\w+)(?<!lb) Rear Axle$
Revised: 2010-03-26
Copied!