M
M
mrSaizer2021-04-18 17:23:46
Regular Expressions
mrSaizer, 2021-04-18 17:23:46

How to remove spaces in urls using sublime text 3 regular expressions?

Good afternoon!

There is html code:

src=" https://hips.hearstapps.com/hmg-prod.s3.amazonaws.com/images/2974023891-71d73973f8-b-1538153205.jpg "

in which the link to the image inside the src is filled with random spaces. (the location of the spaces in the url and their number is not static: it can be near slashes, it can be after/before the dot, near the protocol, etc.)
How can they be cleaned? Preferably through replacement with regular expressions.

I forgot to add, the replacement should only work on urls - the replacement should not work on other elements / tags of the html code :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WbICHA, 2021-04-18
@WblCHA

/src=".*?\s+.*?"/

D
dodo512, 2021-04-18
@dodo512

(src="|\G(?!\A))[^\s"]*\K\s
https://regex101.com/r/q0jclY/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question