[英]How to: RegEx in PhpStorm's Find & Replace
I have this batch process where I need to refactor svg path's.我有这个批处理过程,我需要重构 svg 路径。 Because I have many occurrences in my project and I'm a lazy guy, I prefer to solve this task with find and replace as Regular Expression.
因为我的项目中出现了很多情况并且我是一个懒惰的人,所以我更喜欢使用 find 和 replace 作为正则表达式来解决这个任务。
What I have:我拥有的:
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/_ui/desktop/common/images/svg/icons.svg#icon-arrow--white"></use>
What I want in the end:我最终想要的是:
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#icon-arrow--white"></use>
My regex looks like this:我的正则表达式如下所示:
xlink="(.*)#
and its valid for my string on http://regex-testdrive.com/en/dotest and other sites.它对我在http://regex-testdrive.com/en/dotest和其他网站上的字符串有效。
How come, that if I use this expression in PhpStorm that it is not valid.怎么会,如果我在 PhpStorm 中使用这个表达式,它是无效的。 If someone of you guys could provide me a hint, why I get 0 occurrences in PhpStorm with my RegEx, I'd be glad.
如果你们中有人可以给我一个提示,为什么我的 RegEx 在 PhpStorm 中出现 0 次,我会很高兴。
You can use:您可以使用:
xlink:href="[^"]*"
And replace the occurences with xlink:href="#icon-arrow--white"
, see a demo on regex101.com .并用
xlink:href="#icon-arrow--white"
替换出现的情况,请参阅regex101.com 上的演示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.