英文:
Regex to match for repeating numbers in a string
问题
我只想挑选出具有重复数字的行。
Col A
100,100,100,100,100,100,100,100,100,100,100
3,61,3,145,61,61,61,61
299,295,299.5,300,299.5,299
5.98,5.98,397.56,405.51,398.53,7.95,405.51,405.51,398.53
482.14,1522.12,1001.92,1990.39,1000,1999.79
649.36,610.4,1136.75,626.78,590.34
2284.58,1773.35,2169.48,1760.41,1256.36
2979.55,3032.63,3023.23,2505.15
431,154.5,179
302.95,304,304
339.96,159.27,340.74,160.04,153.46,346.54
170,170,170
968.41,8.86,486.5,360.4,102.64
420,500,500
200,250,250
使用正则表达式匹配具有重复数字的行。
- 它们也可以由不匹配的数字分隔开。
英文:
I have a column like this, I only want to pick rows with repeating numbers
Col A
100,100,100,100,100,100,100,100,100,100,100
3,61,3,145,61,61,61,61
299,295,299.5,300,299.5,299
5.98,5.98,397.56,405.51,398.53,7.95,405.51,405.51,398.53
482.14,1522.12,1001.92,1990.39,1000,1999.79
649.36,610.4,1136.75,626.78,590.34
2284.58,1773.35,2169.48,1760.41,1256.36
2979.55,3032.63,3023.23,2505.15
431,154.5,179
302.95,304,304
339.96,159.27,340.74,160.04,153.46,346.54
170,170,170
968.41,8.86,486.5,360.4,102.64
420,500,500
200,250,250
regex match for rows that have repeating numbers
- they can be seperated by non matching numbers as well
答案1
得分: 1
使用捕获组来捕获每个数字,并使用反向引用来匹配数字的重复。
\b(\d+(?:\.\d+)?)\b.*\b\b
英文:
Use a capture group to capture each number, and a back-reference to match a repeat of the number.
\b(\d+(?:\.\d+)?)\b.*\b\b
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论