Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个类似于"Hello 9 you8 [C#587]"或的字符串"Hello 9 you8 [#587]"
"Hello 9 you8 [C#587]"
"Hello 9 you8 [#587]"
我需要检查字符串是否包含"[#numbers]"或"[letter#numbers]"在 C# 中使用正则表达式。
"[#numbers]"
"[letter#numbers]"
请协助。
亲切的问候
实际上,“字母”部分可能是一个词。
请根据更新提供帮助。
谢谢
试试这个,
\[([A-Za-z]+)?#(\d)+\]
尝试使用以下正则表达式:
\[[a-zA-Z]?#\d+\]
我相信您想要与@hsz 的答案略有不同的东西。他只会检查[letter#numbers]而不是检查[#numbers]。
[letter#numbers]
[#numbers]
试试这个: