Match and replace

后端 未结 5 2084
有刺的猬
有刺的猬 2020-12-08 14:03

I have a long string and within that string I have the following text:

\"formatter\": \"SomeInformationHere\"

I need to fi

5条回答
  •  误落风尘
    2020-12-08 14:53

    Most probably "the replacement seems to work as if the "singleline" option has been selected" beacause the initially used by you regex will match correctly up to the 14th symbol in

    **"formatter": "SomeInformationHere"**
    

    , but after that it will match every symbol nomatter what it is, including the next fist occurance of double quotes, and it will continue untill the first new line. That's how .* expression works because of it's greedness (Check greedy vs lazy regex). So I suppose that you have only to modify

    "\"formatter\": ([\"]).*([\"])"
    

    to

    "\"formatter\": ([\"]).*?([\"])"
    

提交回复
热议问题