简体   繁体   中英

How to: RegEx in PhpStorm's Find & Replace

I have this batch process where I need to refactor svg path's. 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.

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.

How come, that if I use this expression in PhpStorm that it is not valid. If someone of you guys could provide me a hint, why I get 0 occurrences in PhpStorm with my RegEx, I'd be glad.

You can use:

xlink:href="[^"]*"

And replace the occurences with xlink:href="#icon-arrow--white" , see a demo on regex101.com .

Next to the field where you input your search string (in your case your regex), there's a box to enable regex in search:

在此处输入图片说明

Simply check Regex , the regex is working then.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM