RegEx ActionScript 3 [cerrado]
Frecuentes
Visto 90 veces
0
I am trying to figure out a regex to strip extra single quotes so that I would end up with only one single quote. To explain my question better, here is an example.
Let's say I have 3 different strings such as this ones.
(dos comillas simples)
Name<span fontSize=''16'' baselineShift=''superscript''>ABC</span>
(three single quotes)
Name<span fontSize='''16''' baselineShift='''superscript'''>ABC</span>
(four single quotes)
Name<span fontSize=''''16'''' baselineShift=''''superscript''''>ABC</span>
I am trying to sanitize the string to end up with this:
Name<span fontSize='16' baselineShift='superscript'>ABC</span>
I tried several online tools. This one is my favourite one: http://ryanswanson.com/regexp/#start. But I just can't get it right.
Could someone please help me out? Any tips and suggestions would be greatly appreciated.
Gracias de antemano!
2 Respuestas
2
Has probado '+
?
var str:String = "Name<span fontSize=''''16'''' baselineShift=''''superscript''''>ABC</span>";
trace( str.replace(/'+/g, "'") );
Respondido el 10 de Septiembre de 13 a las 01:09
1
Have you looked at the docs for AS3's RegEx code? AS3 Replace Podrías probar algo como esto
var myPattern:RegExp = /'{2,100}/g;
var str:String = "fontSize=''''16''''";
trace(str.replace(myPattern, "'"));
The '{2,100} essentially looks for a match of ' that occurs between 2 - 100 times and replaces it with a single '.
Respondido el 10 de Septiembre de 13 a las 01:09
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas regex actionscript-3 or haz tu propia pregunta.
I am just slapping my forehead right now. :) Thank so much, Marty! - bustedsanta