M
M
Mikhail Lyalin2020-07-16 13:39:48
Regular Expressions
Mikhail Lyalin, 2020-07-16 13:39:48

How to replace http with https in the URL for a domain and subdomains on it using a regular expression?

How to replace http with https in the URL for a domain and subdomains on it using a regular expression?

I'm looking through http://(([^.]+)\.)?livejournal\.com/

And what should I use to change only https at the beginning in the found URLs and leave everything else unchanged?

Example: found anhar.livejournal.com/3205896.html - received https://anhar.livejournal.com/3205896.html

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-07-16
@mr_jok

Find: http://(([^.]+\.)?livejournal\.com/)
Replace:https://$1

D
Developer, 2020-07-16
@samodum

From a cannon to sparrows. Why regular?
It's easier to use replace('http://', ​​'https://')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question