ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Regular expression problem (https://www.excelbanter.com/excel-programming/454812-regular-expression-problem.html)

RG III

Regular expression problem
 
Using only regular expressions, how do you match the
pattern of the same digit that occurs three times in
a string, separated by one character?

Examples:

0a0a0 ' 0 occurs three times separated by "a"
9x9x9 ' 9 occurs three times separated by "x"
1:1:1 ' 9 occurs three times separated by ":"

Robert

Adrian Caspersz

Regular expression problem
 
On 24/06/2020 10:47, RG III wrote:
Using only regular expressions, how do you match the
pattern of the same digit that occurs three times in
a string, separated by one character?

Examples:

0a0a0 ' 0 occurs three times separated by "a"
9x9x9 ' 9 occurs three times separated by "x"
1:1:1 ' 9 occurs three times separated by ":"

Robert


using a global match and a capturing group containing alternation

(\d[a|x|:]?){3}

Try it on regex101.com

--
Adrian C


All times are GMT +1. The time now is 04:40 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com