RegExp - паттерны, matches... |
'телеф номер: p = "\b[8|\+7][-.]?\d{3}[-.]?\d{3}[-.]?\d{4}\b"
p = p & "(.{10,30})[Руб.]"
+ source |
</p> <p> </p> </td><td> </td></tr><tr><td width="46%" valign="top"> <u>Билайн 8-965-117-8558</u> <p align="right">Цена: <b>999 Руб.</b> <form action="/"> <input type="hidden" name="type" value="buy" /> <input type="hidden" name="buy_id" value="120085532" /> <div align="right"><input type="submit" value="Купить" style="font-size:10px;" /></div> </form> </p> <p> </p> </td><td> </td><td width="46%" valign="top"> <u>Билайн 8-965-117-8668</u> <p align="right">Цена: <b>999 Руб.</b> <form action="/"> <input type="hidden" name="type" value="buy" /> <input type="hidden" name="buy_id" value="120085533" /> <div align="right"><input type="submit" value="Купить" style="font-size:10px;" /></div> </form> </p> <p> </p> </td><td> </td></tr><tr><td width="46%" valign="top"> <u>Билайн 8-965-118-6556</u> <p align="right">Цена: <b>999 Руб.</b> <form action="/"> <input type="hidden" name="type" value="buy" /> <input type="hidden" name="buy_id" value="120085534" /> <div align="right"><input type="submit" value="Купить" style="font-size:10px;" /></div> </form> </p> <p> </p> </td><td> </td><td width="46%" valign="top"> <u>Билайн 8-965-119-0660</u> <p align="right">Цена: <b>999 Руб.</b> |
+ | ||||
Function HtmlParser(ByVal str As String) ' MsgBox "Test-" & oRgx.Test(" " & _ ' " | " & _
' "МегаФон 8-926-795-1144" & _
' " 1999 Руб.") Dim i As Integer, s As String Dim fso, fld, f, ofsoTxtStream Dim oRgx, orgxMatch, orgxMatcheS Set oRgx = CreateObject("VBScript.RegExp") Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFile(str) Set ofsoTxtStream = f.OpenAsTextStream(1) 'читаем файл в поток, поток в переменную: s = ofsoTxtStream.readall(): ofsoTxtStream.Close ' 'Паттерны: Dim p As String 'телеф номер: p = "\b[8|\+7][-.]?\d{3}[-.]?\d{3}[-.]?\d{4}\b" p = p & "(.{10,30})[Руб.]" oRgx.Global = True oRgx.ignorecase = False oRgx.Multiline = True oRgx.pattern = p 'ТЕСТ: ' MsgBox "Test-" & oRgx.Test(" " & _ ' "" & _ ' " | " & _
' "МегаФон 8-926-795-1144" & _
' " 1999 Руб.") Set orgxMatcheS = oRgx.Execute(s) Debug.Print orgxMatcheS.Count For i = 0 To orgxMatcheS.Count - 1 Set orgxMatch = orgxMatcheS.Item(i) Debug.Print "#############" Debug.Print orgxMatch.FirstIndex Debug.Print orgxMatch.Length Debug.Print "------------" ' Debug.Print orgxMatcheS.Value Debug.Print orgxMatcheS.Count ''''''' Debug.Print orgxMatcheS.Item(i) Debug.Print "============" Next MsgBox "!" Set fso = Nothing: Set fld = Nothing: Set ofsoTxtStream = Nothing: Set f = Nothing Set oRgx = Nothing: Set orgxMatcheS = Nothing: Set orgxMatch = Nothing End Function |
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |