Paulquappe
Paulquappe

Reputation: 144

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.

Upvotes: 1

Views: 989

Answers (2)

baao
baao

Reputation: 73251

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

enter image description here

Simply check Regex, the regex is working then.

Upvotes: 0

Jan
Jan

Reputation: 43169

You can use:

xlink:href="[^"]*"

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

Upvotes: 1

Related Questions