Skip to content
Advertisement

How to split text based on specific word

I have a text which contains the word “Article” many times for example:

My text title Article 1 bla bla Article 2 bla bla …

I want to split the text like this:

JavaScript

Advertisement

Answer

Instead of trying to find a split pattern, you should look for a matching pattern:

JavaScript

It matches Article, followed by anything up to but not including another Article or end of line.

JavaScript

Output:

JavaScript

Edit

To just filter out the Article followed by a number:

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