0
정규 표현식을 사용하여 텍스트의 특정 부분을 찾고 싶습니다. KENNFELD TFSWNWRSA 4 4RegularExpression을 사용하여 텍스트의 특정 부분 추출하기
내가 KENNFELD이 텍스트 만 TFSWNWRSA 4 4하지 압축을 한 후 나는이 코드를 작성
를 원하지만 예를 들어 내가 좋아하는 텍스트를 모든 전체 행을 반환합니다.
Dim fso As New FileSystemObject
Dim ts As TextStream
Dim Name As String
Dim regx As New regexp
Dim matchkennfeld As MatchCollection
Dim matchname As MatchCollection
Name = "D:/test_DC.txt"
'Set regexp = CreateObject("vbscript.regexp")
Set ts = fso.OpenTextFile(Name, ForReading)
Do While Not ts.AtEndOfStream
regx.Pattern = "KENNFELD\s+([A-Z 0-9]*)"
Set matchkennfeld = regx.Execute(ts.ReadLine)
If matchkennfeld.Count <> 0 Then
regx.Pattern = "([A-Z 0-9]*)"
' MsgBox matchkennfeld.Item(0)
Set matchname = regx.Execute(matchkennfeld.Item(0))
For Each Match In matchname
MsgBox Match
Next Match
End If
Loop
이 작업을 도와 주시겠습니까?
[this] (http://regex101.com/r/qV5jJ5)와 같은 의미입니까? – HamZa
하지만 이것으로 나는 완전한 텍스트를 가지고 있습니다. TFSWNWRSA 4 4 – TangoStar
'm' 수정자를 사용하십시오. – HamZa