[英]regex to exact match 11 digit phone number from string and remove hyphen(-) from match in c#
[英]Pick the exact digit match from a string
我有如下輸入字符串
1)ISBN_9781338034424_001_S_r1.mp3
2)001_Ch001_987373737.mp3
3)這是測試001 Chap01.mp3
4)Anger_Cha01_001.mp3
我使用下面的正則表達式選擇“001”進入TrackNumber組
(?:(?<TrackNumber>\d{3})|(?<Revision>r\d{1}))(?![a-zA-Z])
然而,上面還將“978”,“133”,“803”等拾入TrackNumber組(例1和2)。
如何更改上述正則表達式以僅將“001”選為TrackNumber?
-Alan-
以下正則表達式將匹配所有示例中的3位數軌道號:
(?<=\b|_)(?<TrackNumber>\d{3})(?=\b|_)
(?<=\\b|_)
正向后觀,前一個字符是單詞邊界(即空格)或下划線 (?=\\b|_)
正向前瞻,下一個字符是單詞邊界(即空格)或下划線
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.