Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regular expression to find the longest recurring character sequence in a line

Tags:

regex

How do I write a regular expression to find the longest recurring character sequence in a line?

like image 822
Aadith Ramia Avatar asked Dec 02 '10 13:12

Aadith Ramia


1 Answers

You can find all relevant character sequences with the regular expression /(.)\1*/.

Finding the longest such sequence is best done using a tool other than regular expressions.

like image 51
Mark Byers Avatar answered Nov 15 '22 09:11

Mark Byers