Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/09/2011, 18:18
marco64yes
 
Fecha de Ingreso: septiembre-2010
Mensajes: 350
Antigüedad: 12 años, 2 meses
Puntos: 9
Exclamación Expresiones regulares validar salto de linea

Hola que tal amigos!! tengo una ultia duda para terminar mi rompecabezas o mas bien el rompecabezas para los demas jaja

El problema esta asi:

Cuento con este codigo:

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

(agradezco de ante mano a _cronos y zerokilled por la ayuda)

Los datos de entrda son:

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 
Aceite de hígado de bacalao 100 0.0 901 0.0 0.0 99.9 4.5 47.5 34.5 500 0.0 0 0 0 0 0
0.00 
Aceite de maíz 100 0.0 884 0.0 0.0 100.0 13.4 31.6 50.9 2 0.0 1 1 0 15 
Los datos de salida con ese codigo son:

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,0,5.8,1.8,0,0.0,22,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,,0.0,0,0,0,0,0,0.03
|Aceite de hígado de bacalao'
,100,0.0,901,0.0,0.0,99.9,4.5,47.5,34.5,50 0,0.0,0,0,0,0,0?,0.00
|Aceite de maíz'
,100,0.0,884,0.0,0.0,100.0,13.4,31.6,50.9,2,0 .0,1,1,0,15
|' 
Si se dan cuenta:

Aceite de maíz',100,0.0,884,0.0,0.0,100.0,13.4,31.6,50.9,2,0 .0,1,1,0,15'
|'

el acento simple imbade al final.. y eso es por este codio:

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

Yo deseo que resultado final sea:

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
Como le puedo hacer amigos?? de ante mano muchas gracias por la pasiencia ;)
Sé que con estas dudas muchos saldran de apuros =) !!!