Sunday, 15 July 2012

regex - How to write a Regexp for any character, but it must be the same a specific number of times -


I want to find a string that can be the same character in the line, this can be any letter (including NULL char) , So I can not specify which is the character, but it is 20 or more times in the queue.

dot "." Match any character, but how do I specify in a RegExp, that it should be of the same character if I do not know from whom?

Example: Bla bla blub oooooooooooooooooo xxxxxxxxxxxxxxx should be in the string.

I want to find OS and X lines. "{10,}" matches any row.

You can capture a letter and then refer back to 1 bar 9 times whether a The letter has been repeated 10 times:

  / ([A-Za-z]) \ 1 {9,} / g  

PS: To check any character usage:

  / (.) \ 1 {9,} / g  

No comments:

Post a Comment