2013-12-20 3 views
1

어떻게 이름을 얻을 수 있습니까?Visual Basic 2013 RegEx

"안녕 이름!"

Dim r As New Regex("Hello (.*)! :)") 
      Dim matches As MatchCollection = r.Matches(Chat) 
      For Each m As Match In matches 
       MsgBox("Hi " & m.ToString & " and welcome back!") 
      Next 

답변

3

에만 이름을 얻으려면 (채팅 마지막 Chatmessage입니다), 당신은 Groups를 사용해야합니다. 당신이 정말로 :) 일치 할 경우, 당신은 \를 사용하여 )을 탈출해야합니다

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 
1

당신이 문자열 안녕하세요에 대한 대체하지 않는 이유! 아시다시피 이들은 고정되어 있습니까 ??

VB는 모르지만 다른 언어의 REGEX는 여야합니다 (\ S +)!