Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: Trudne wyrażenie regularne
Forum PHP.pl > Forum > PHP
permanent
Robie skaner plików on-line, a raczej pobieranie wyników ze strony skanującej i mam problem z wyrażeniem regularnym. Dostaje tekst w ciągu:

Kod
Complete scanning result of "Project2.pdf", processed in VirusTotal at 02/19/2009 01:05:17 (CET). [ file data ] * name..: Project2.pdf * size..: 385536 * md5...: 85f3697601a2a3d3ae6e4a4e71413314 * sha1..: 68cf1e05c28e151ccb702e01f476787201820291 * peid..: BobSoft Mini Delphi -> BoB / BobSoft [ scan result ] a-squared 4.0.0.93/20090218 found nothing AhnLab-V3 2009.2.19.0/20090218 found nothing AntiVir 7.9.0.83/20090218 found [TR/Spy.Gen] Authentium 5.1.0.4/20090218 found nothing Avast 4.8.1335.0/20090218 found [Win32:Spyware-gen] AVG 8.0.0.237/20090219 found [PSW.Banker] BitDefender 7.2/20090219 found nothing CAT-QuickHeal 10.00/20090218 found nothing ClamAV 0.94.1/20090218 found nothing Comodo 983/20090218 found nothing DrWeb 4.44.0.09170/20090219 found nothing eSafe 7.0.17.0/20090218 found nothing eTrust-Vet 31.6.6364/20090219 found nothing F-Prot 4.4.4.56/20090218 found nothing F-Secure 8.0.14470.0/20090218 found [Suspicious:W32/Malware!Gemini] Fortinet 3.117.0.0/20090218 found nothing GData 19/20090219 found [Win32:Spyware-gen ] Ikarus T3.1.1.45.0/20090218 found nothing K7AntiVirus 7.10.630/20090218 found nothing Kaspersky 7.0.0.125/20090219 found nothing McAfee 5529/20090217 found nothing McAfee+Artemis 5529/20090217 found nothing Microsoft 1.4306/20090218 found nothing NOD32 3866/20090218 found nothing Norman 6.00.06/20090218 found nothing nProtect 2009.1.8.0/20090218 found nothing Panda 9.4.3.20/20090218 found nothing PCTools 4.4.2.0/20090218 found nothing Prevx1 V2/20090219 found nothing Rising 21.17.22.00/20090218 found nothing SecureWeb-Gateway 6.7.6/20090218 found [Trojan.Spy.Gen] Sophos 4.38.0/20090218 found nothing Sunbelt 3.2.1855.2/20090217 found nothing Symantec 10/20090219 found nothing TheHacker 6.3.2.2.259/20090218 found nothing TrendMicro 8.700.0.1004/20090218 found nothing VBA32 3.12.10.0/20090218 found nothing ViRobot 2009.2.18.1613/20090218 found nothing VirusBuster 4.5.11.0/20090218 found nothing


Tak wygląda po sformatowaniu:



W jaki sposób mogę zwrócić ZAZNACZONE ciągi tekstu? Przypominam, że tekst otrzymuje ciągiem, więc odpada jakieś bawienie się z nową linią. Na razie udało mi się uzyskać tylko to:

  1. <?php
  2. $zmienna = "|found [[A-Za-z0-9./:!-s]+])|i";
  3. ?>


Czyli mam już przykładowo:

found [TR/Spy.Gen]

teraz w jaki sposób mogę wyciągnąć resztę?
ayeo
Witam!

  1. <?php
  2. $patten = "#s[^s|.]+?s[d|.]+/200[d]{5}sfounds[.*?]#i";
  3. ?>


Działa, testowałem. Jednak łatwiej jest zamieniać "nothing" i "[scan result]" na "\r\n", a potem:

  1. <?php
  2. $pattern = "#^.*?]$#";
  3. ?>


Pozdrawiam!

PS Przyzwyczaj się do myśli, że przed preg_match poprawiasz treść biggrin.gif
permanent
Nie wiem jak mam Ci dziękować. biggrin.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.