S
S
Svoboo2022-02-22 12:00:46
Regular Expressions
Svoboo, 2022-02-22 12:00:46

How to make a regular program to get a domain zone?

There is a list of domains and subdomains of this kind:

site.ru
lalal.sasa.com
and so on

Tell me how to make a regular expression so that it pulls out the domain zone after the last dot in the line?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Svoboo, 2022-02-22
@Svoboo

/([^.]+)$/

V
vreitech, 2022-02-22
@fzfx

(?<=\.)\w+(?=\.?$)
This regular expression "matches" alphanumeric characters located after the dot, and either before the end of the line, or before the dot with the end of the line after it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question