Regex Visual Basic 2013正则表达式
我怎么才能只知道名字 “你好姓名!”Regex Visual Basic 2013正则表达式,regex,vb.net,visual-studio,Regex,Vb.net,Visual Studio,我怎么才能只知道名字 “你好姓名!” (Chat是最后一条聊天信息)若要仅获取姓名,应使用组。如果您真的想匹配:),则必须使用\来转义): Dim Chat As String = "Hello Name!" Dim r As New Regex("Hello (.*)! :\)") Dim matches As MatchCollection = r.Matches(Chat) For Each m As Match In matches m.Groups(1).Value Next
(Chat是最后一条聊天信息)若要仅获取姓名,应使用
组
。如果您真的想匹配:)
,则必须使用\
来转义)
:
Dim Chat As String = "Hello Name!"
Dim r As New Regex("Hello (.*)! :\)")
Dim matches As MatchCollection = r.Matches(Chat)
For Each m As Match In matches
m.Groups(1).Value
Next
要仅获取名称,应使用
组
。如果您真的想匹配:)
,则必须使用\
来转义)
:
Dim Chat As String = "Hello Name!"
Dim r As New Regex("Hello (.*)! :\)")
Dim matches As MatchCollection = r.Matches(Chat)
For Each m As Match In matches
m.Groups(1).Value
Next
为什么不为Hello和做一个字符串替换呢如您所知,这些是固定的
我不知道VB,但是其他语言的正则表达式应该是Hello(\S+)为什么不为Hello和做一个字符串替换呢如您所知,这些是固定的 我不知道VB,但是其他语言的正则表达式应该是Hello(\S+)强>