正则表达式:忽略字符串的一部分 [英] Regex: Ignore a part of the string
问题描述
我需要一个忽略部分字符串的正则表达式
I need a regex expression that ignores a part of a string
示例:
盲注 $100/$200 - 锦标赛 2020202220
Blinds $100/$200 - Tournament 2020202220
盲注 $100/$200 底注 20 - 锦标赛 2020202220
Blinds $100/$200 Antes 20 - Tournament 2020202220
我正在使用这个表达式:
im using this expresion:
Blinds\s[$€](100)/[$€\d]+\s(Ante\s[$€\d]+\s)?.*
但它匹配两个字符串...
but it match for both strings...
我需要的是一个匹配第一种情况而忽略第二种情况的表达式以及与第二个匹配但忽略第一个的第二个表达式.
What i need is an expression that match the first case and ignore the second and a second expression that matchs the second but ignores the first.
我对正则表达式不是很熟悉...提前致谢
im not very familiar with regex expressions ... thanks in advance
推荐答案
第一行
这将匹配第一行
Blinds\b\s*([$€]\d*/[$€]\d*)\s*[-]\s*\bTournament\b\s*(\d*)
捕获的组:
第 0 组:100 美元/200 美元的盲注 - 锦标赛 2020202220"
group 0: "Blinds $100/$200 - Tournament 2020202220"
- $100/$200"
- 2020202220"
第二行
Blinds\b\s*([$€]\d*/[$€]\d*\s*Antes\s*\d*\s*)[-]\s*Tournament\s*(\d*)
捕获的组:
第 0 组盲注 $100/$200 底注 20 - 锦标赛 2020202220"
group 0 "Blinds $100/$200 Antes 20 - Tournament 2020202220"
- $100/$200 底注 20"
- 2020202220"
这篇关于正则表达式:忽略字符串的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!