A
A
Alex Wells2015-10-23 23:29:35
PHP
Alex Wells, 2015-10-23 23:29:35

How to make a RegEx to replace any domains with a string?

Greetings. There is a task - to replace all domains in a string with another string, and also if a domain is found - to return true. How to do it? Regulars from the database will not help here, and I myself am a complete zero in them and all my attempts to understand anything were unsuccessful)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2015-10-24
@Alex_Wells

( http://)?([^\n ]+\.)?([^.\n ]+\.)([^.\n ]+)
still indicate the kind of data that you consider a domain, for example http:// etc.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question