Reputation: 109
Say you have:
www.example.co.uk/about
www.example.co.uk/help
www.example.co.uk/goats
etc (but multiplied by several hundred). In phpstorm, or any other editor for that matter, how can i turn the selection to:
'/about' => '/',
'/help' => '/',
'/goats' => '/',
Tried with find and replace by no luck
Upvotes: 0
Views: 298
Reputation: 627128
Here is a regex that will match the last parts of URLs after the last /
and replace the strings as required:
(?m)^.*?(\/[^\/\n]+)$
Replace with '$1' => '/',
.
See demo
The regex matches
(?m)
- forces ^
to match the beginning of a line^
- the beginning of a line.*?
- 0 or more characters other than a newline as few as possible(\/[^\/\n]+)
- literal /
and 1 or more characters other than /
or a newline$
end of lineUpvotes: 1