D
D
Demigodd2020-11-20 17:06:59
ruby
Demigodd, 2020-11-20 17:06:59

How to add the word test after www. in the URL?

For example, there is a link like

http://www.google.com
https://www.google.com
www.google.com
www.gowww.ogle.com
google.com


how to get such an option from all this?
http://www.test.google.com
https://www.test.google.com
www.test.google.com
www.testgowww.ogle.com
test.google.com

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-11-20
@Demigodd

toInsert = 'test.'
newStr = str.dup.sub!(/(?<=www\.)/, toInsert) || (toInsert + str)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question