For exampleaaabccc11fdsa
This string, I want to match strings like aaa, ccc and 11 that will be repeated more than twice. What should I do? If regular expressions can't do it, are there any other PHP or Python built-in functions that can do it? If there are no built-in functions, can we only write the algorithm by hand?
学习ing2017-06-19 09:08:59
You can match it with a simple regular expression. I only know js.
var s = 'aaabccc11fdsa';
var reg = /(\w)+/ig;
console.log(s.match(reg)); //["aaa", "ccc", "11"]
PHP中文网2017-06-19 09:08:59
JS code:
var s = 'aaabccc11fdsa';
var re = /.{2,}/g;
console.log(s.match(re));
Among them, .
in the regular expression means any character {2,}
means matching twice or more.