🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #740

Expresion Regular II

#740
From: Pintamono
Date: Fri, 19 Oct 2007 16:55
50 lines
1877 bytes
Tengo la siguiente expresion regular:

([SNsn])([a-zA-Z0-9 ]+)\s([a-zA-Z0-9 ]+)\r\n([\s\S]*)

Esta expresion me acepta texto del tipo

|S150 RTF3434
1 23 4 5 6 7 8 9 0 

Y
|S150   RTF3434
1 23 4 5 6 7 8 9 0 

Pero no me deja obviar el segundo campo de la primera linea, es decir...

|S150 
1 23 4 5 6 7 8 9 0 

Esto no pasa.

Considerando que el * es el comodin

Probe con

([SNsn])([a-zA-Z0-9 ]+)\s*([a-zA-Z0-9 ]+)\r\n([\s\S]*)
([SNsn])([a-zA-Z0-9 ]+)\s(*[a-zA-Z0-9 ]+)\r\n([\s\S]*)
([SNsn])([a-zA-Z0-9 ]+)\s([a-zA-Z0-9 ]*+)\r\n([\s\S]*)

Sin obtener resultados positivos...


Como puedo dejar la expresion para que el segundo campo aparezca 0 o 1 vez 
solamente?

Gracias!!!

Nota: Lo que necesito es ingresar texto del tipo

|S150 RTF1
1 avisos 23 4 5 6 7 8 9 0 
|S151 RtF2 
2 avisos 23 4 5 6 7 8 9 0 
|S505  rtf3
3 avisos 23 4 5 6 7 8 9 0 
|S460 
4 avisos 23 4 5 6 7 8 9 0 
|S200  ftr4
5 avisos 23 4 5 6 7 8 9 0 
|S800  ppp5
6 avisos 23 4 5 6 7 8 9 0 
Technical Details
Message-ID: <73a2d0f1f74ebfdede4c3cc14a267ce5$1@usenet.no-ip.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,8b91cd4b54ad36b9,start
X-Google-Attributes: gid1593cb,public,usenet
X-Google-Language: SPANISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!news.kjsl.com!news.nivel5.cl!not-for-mail
From: pintamono@NoMandeWeas.kk (Pintamono)
Newsgroups: chile.comp.programacion
Subject: Expresion Regular II
Date: Fri, 19 Oct 2007 12:55:26 -0400
Organization: Usenet Chile.* http://usenet.no-ip.com
Lines: 51
Message-ID: <73a2d0f1f74ebfdede4c3cc14a267ce5$1@usenet.no-ip.com>
NNTP-Posting-Host: pc-146-86-104-200.cm.vtr.net
Mime-Version: 1.0
X-Trace: news.nivel5.cl 1192809320 32072 200.104.86.146 (19 Oct 2007 15:55:20 GMT)
X-Complaints-To: news@news.nivel5.cl
NNTP-Posting-Date: Fri, 19 Oct 2007 15:55:20 +0000 (UTC)
User-Agent: NewsPortal/0.3X RCL MOD
X-Abuse: robertocl@gmail.com
X-HTTP-Posting-Host: 200.27.140.110