Skip to content
Advertisement

Get index of first dot with letter in a string

I have a string like this one:

dsl-34.345.324-24718.pool.vodafone9.com (not a real hostname, just an example)

I’ve already tinkered around with preg_split which didn’t gave me the good result.

Anyway, I’d like to get this result:

pool.vodafone9.com

EDIT

Sorry, for not showing directly what I did with preg_split(), I already thought about doing that, however, it would have resulted into a completely wrong result when there are numbers within the domain.

JavaScript

put out

ools.vodafone.com

but with vodafone9.com it would have resulted in

om

Advertisement

Answer

Try using this regular expression to detect everything after the first . followed by a single letter:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement