Ver Mensaje Individual
  #15 (permalink)  
Antiguo 02/09/2011, 16:07
marco64yes
 
Fecha de Ingreso: septiembre-2010
Mensajes: 350
Antigüedad: 14 años, 1 mes
Puntos: 9
Exclamación Respuesta: Expresion regular para validar texto

Cita:
Iniciado por zerokilled Ver Mensaje
ohhhhh cierto, error mio! lo copie mal de la prueba que habia hecho... dentro de los corchetes y al final, agrega \s.
Que tal,, oye tengo una duda, yo pongo:

campoTextArea = campoTextArea.replace(/\s(?=\d)/g, ',');
campoTextArea = campoTextArea.replace(/[a-z\xc0-\xff\s]+/gi, "'$&'");

El contenido:

Aceite de cacahuete 100 0.4 878 0.0 0.0 99.4 13.0 53.0 24.6 1 0.0 0 0 0 0 0 0.06
Aceite de coco 100 0.0 884 0.0 0.0 100.0 **.* 5.8 1.8 0 0.0 2 2 0 2 1 0.04
Aceite de germen de trigo 100 0.0 879 0.0 0.0 99.5 17.2 15.7 64.7 0 0.0 0 0 0 0 0

El resultado:

Código PHP:
'Aceite de cacahuete',100,0.4,878,0.0,0.0,99.4,13.0,53.0,24.6,1,0.0,0,0,0,0,0,0.06
Aceite de coco'
,100,0.0,884,0.0,0.0,100.0' '**.*,5.8,1.8,0,0.0,2,2,0,2,1,0.04
Aceite de germen de trigo'
,100,0.0,879,0.0,0.0,99.5,17.2,15.7,64.7,0,0.0,0,0,0,0,0,0.00
Aceite de girasol'
,100,0.2,882,0.0,0.0,99.8,11.0,22.4,60.7,2,0.0,0,0,0,0,0,0.03 
El resultado deseado:

'Aceite de cacahuete',100,0.4,878,0.0,0.0,99.4,13.0,53.0,24.6 ,1,0.0,0,0,0,0,0,0.06|
'Aceite de coco',100,0.0,884,0.0,0.0,100.0' '**.*,5.8,1.8,0,0.0,2,2,0,2,1,0.04|
'Aceite de germen de trigo',100,0.0,879,0.0,0.0,99.5,17.2,15.7,64.7,0,0 .0,0,0,0,0,0,0.00

No se si sean los saltos de linea... que ocacione eso..
Como pudo hacer para que cada final de la sentencia me ponga un pipe |
??

Muchas,gracias

Última edición por marco64yes; 02/09/2011 a las 17:16