Search code examples
javascriptstringsubstr

javascript grab part of a string after a . (dot)


I'm unable to read regex.

Let's say we have this string: "mydomain.bu.pu" and I want to grab the ".bu.pu" part of it;

I'm thinking about using something like:

indexOf and later substr ... But I confess I'm kind of lost...

Any help please? :D

Thanks in advance, MEM


Solution

  • var afterDot = str.substr(str.indexOf('.'));