How find/replace special character + with space regular Expression in SRC=“”

问题内容:

Hello i’m trying with notepad ++ to find in SRC of tag special characters + and replace with space with regular expression.

For example src=”www.miosito.it/image/la+sagra+della+porchetta.jpg”

I want to replace each + with space with regular expression so: src=”www.miosito.it/image/la sagra della porchetta.jpg”.

Helppppppp
Thanks
Fabrizio

问题评论:

2  
(?:\bsrc="|\G(?!\A))[^+]*\K\+ replace with space

答案:

答案1:

As per my original comment…

Code

See regex in use here

(?:\bsrc="|\G(?!\A))[^+]*\K\+

Alternatively, you can use (?:\bsrc="|\G(?!\A)).*?\K\+, but the other regex gives better performance.

Replacement: (space)


Results

Input

src="www.miosito.it/image/la+sagra+della+porchetta.jpg"

Output

src="www.miosito.it/image/la sagra della porchetta.jpg"

Explanation

  • (?:\bsrc="|\G(?!\A)) Match either of the following
    • \bsrc="
      • \b Assert position as a word boundary
      • src=" Match this literally
    • \G(?!\A) Assert position at the end of the previous match
  • [^+]* Match any character except + any number of times. The alternative uses .*? which matches any character any number of times, but as few as possible
  • \K Resets the starting point of the reported match. Any previously consumed characters are no longer included in the final match
  • \+ Match + literally

答案评论:

原文地址:

https://stackoverflow.com/questions/47756138/how-find-replace-special-character-with-space-regular-expression-in-src

添加评论

友情链接:蝴蝶教程