[英]How can I check if a string is ONLY one char and is either * or ? or _ via Regex?
[英]Regex and (char)30 How can I define
我有一個代碼。 我正在使用正則表達式。
string s = "1-2-3-4-5" (Instead of "-" there is ctr + Shift + "-" in Office Word)
Regex regex = new Regex(@"\d*-\d*-\d*-\d*-\d*");
WordsCount = regex.Matches(s).Count;
有一個 char[30](ASCII 記錄分隔符)而不是“-”。 如何定義我的搜索? 我需要做這樣的事情: (@"\d*-|char(30)\d*-|char(30)\d*-|char(30)\d*-|char(30)\d*");
我找到了答案。
(@"\d*(-|\036)\d*(-|\036)\d*(-|\036)\d*(-|\036)\d*");
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.