Skip to content
Advertisement

How to split with Dot without splitting links [duplicate]

I want to split on dot (.) but I don’t want to splits the links.

Let’s say the string is –

JavaScript

Expected Output –

JavaScript

Current Output –

JavaScript

Note that I don’t want the link to split. Also, I know you can split it using .split(".") but how can I not split that link?

Advertisement

Answer

Solution 1: Strings objects have a method called ‘split’:

JavaScript

That takes a string and split by a substring such as ‘.’.

Solution 2: find the position of ‘.’ in the string, then split it manually:

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