Home > Software design >  RE treat whitespace as one word
RE treat whitespace as one word

Time:01-02

New to regex (python). I have a data set that looks like this

{"Model": "NV3500 HD Cargo"},{"Model": "Armada"},{"Model": "Rogue"}, {"Model": "Frontier Crew Cab"},{"Model": "NV2500 HD Cargo"}, {"Model": "TITAN XD Single Cab"},{"Model": "Altima"},

I am attempting to only match what model value is IE NV3500 HD Cargo or Frontier Crew Cab

I am using this expression to match \b(?!Model\b)\w

it matches the correct terms however with models that have spaces it treats them as induvial matches

enter image description here

How can I treat it as one word

CodePudding user response:

\b(?!Model\b)([\w\s] )

Put also it in group.

if you want to capture symboles also, use

\b(?!Model\b)([^\"] )
  • Related