Regex match up to first PRECEDING space from character -
i have snippet here
agent=mozilla/5.0 (windows nt 6.0; wow64; trident/6.0; rv:11.0) gecko custom1=custom1 custom2=custom2 more=otherstuffi dont care etc what want regex matches here
agent=mozilla/5.0 (windows nt 6.1; wow64; trident/7.0; rv:11.0) gecko i have tried this:
agent=(.*?=) which gives me:
agent=mozilla/5.0 (windows nt 6.0; wow64; trident/6.0; rv:11.0) gecko custom1= but custom1 fewer or more chars sometimes.. don't want specific want before space between gecko , custom if browser/os isn't exact might not gecko. feel best way use next = (after custom1) since there.
so if can custom1= agent , match whats before space before custom1, work.
or on complicating this?
thanks.
i suggest following:
agent=([^=]*)(?=\s) this match many characters besides = can, stop before final space.
test live on regex101.com.
Comments
Post a Comment