🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #1738

Re: consulta php preg_match y tipos de variables

#1738
From: Cristian Gutierrez
Date: Tue, 06 Jun 2006 21:46
38 lines
2416 bytes
Hoy en la tarde, Rick oj dijo:
> bueno necesito obtener unos datos de un log, buscando en phpclasses.org 
> encontre "Apace log parser", mire el archivo con el fin de saar una idea y 
> encontre que utiliza la funcion preg_match verifica un patron y si 
> corresponde lo almacena en un arreglo, la funcion recibe estos parametros
>
> preg_match("/^(\S+) (\S+) (\S+) \[([^:]+):(\d+:\d+:\d+) ([^\]]+)\] \"(\S+) 
> (.*?) (\S+)\" (\S+) (\S+) (\".*?\") (\".*?\")$/", $matches);
>
> mi duda es que no entiendo que es \S+ (asumo string) \d+

\s    == caracter "whitespace" (blancos, tabs)
\S    == caracter NO whitespace (alfanumericos, puntuacion, etc)
algo+ == algo una o mas veces

 ==> \S+ == uno o mas caracteres NO blancos NI tabs

Mas info en <http://www.php.net/manual/en/reference.pcre.pattern.syntax.php>.

> alguien me podria explicar se supone que parse el log de apaxhe que es del 
> tipo
>
> 172.0.0.1 - - [21/Sep/2005:23:06:41 +0100] "GET / HTTP/1.1" 404 - "-" 
> "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050712 
> Firefox/1.0+" 

Es el "Common Log Format". Mas info en
<http://httpd.apache.org/docs/1.3/logs.html#common>.

Probablemente te convenga usar la interfaz de esa clase PHP que
conseguiste (o incluso Apache::ParseLog si puedes ocupar Perl) en vez de
repetir el parsing con codigo propio.

Salu2,

-- 
Guti
BTW, FWIW, IMHO, AFAIK, yes. OTOH, AAMOF, maybe not. YMMV.
Technical Details
Message-ID: <87pshm2c0q.fsf@guti.cl>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!news.cec.uchile.cl!not-for-mail
References: <e64rlm$9kc$1@news.nivel5.cl>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,5ee13cd680b85cc4
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news.glorb.com!nntp-server.pubsub.com!news.nivel5.cl!news.cec.uchile.cl!not-for-mail
From: Cristian Gutierrez <crgutier@dcc.uchile.cl>
Newsgroups: chile.comp.programacion
Subject: Re: consulta php preg_match y tipos de variables
Date: Tue, 06 Jun 2006 17:46:13 -0400
Organization: DCC/Uchile
Lines: 38
Message-ID: <87pshm2c0q.fsf@guti.cl>
References: <e64rlm$9kc$1@news.nivel5.cl>
NNTP-Posting-Host: vpn-client-023.cec.uchile.cl
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: localhost.localdomain 1149630373 12540 172.17.35.23 (6 Jun 2006 21:46:13 GMT)
X-Complaints-To: news@localhost.localdomain
NNTP-Posting-Date: Tue, 6 Jun 2006 21:46:13 +0000 (UTC)
User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux)
Cancel-Lock: sha1:QLeMfVwfNud4N7Fcg38c7wNlWQs=