Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-29-2010, 12:51 AM   PM User | #1
loki421
Regular Coder

 
Join Date: Feb 2009
Location: Worcester
Posts: 172
Thanks: 13
Thanked 6 Times in 6 Posts
loki421 is an unknown quantity at this point
Escape an empty tag in a string?

Hi guys,

I am trying to escape an empty tag in a string.

I have a bizzare error when I pass a RichTextEditor HTML text to a string, if I add a line break before I start the bullet points, it adds an empty <li></li> which I would like to remove.

Here's the code I'm using to escape the rest of the formating:

Code:
private function scanTxt():void{
    txtVar = richtexteditor.htmlText;
    var pattern:RegExp = /<TEXTFORMAT.*?>/g;
    txtVar = txtVar.replace(pattern, "");
    pattern = /<FONT.*?>/g;
    txtVar = txtVar.replace(pattern, "");
    pattern = /<\/FONT.*?>/g;
    txtVar = txtVar.replace(pattern, "");
    pattern = /<\/TEXTFORMAT.*?>/g;
    txtVar = txtVar.replace(pattern, "");
    // this is where i'm stuck, i want it to look for <li></li> (an empty list item tag)
    pattern = /<\/LI><\//LI>/g;
}
Does anyone know what the correct syntax is to look for an empty tag and escape it?

Or, is there something I'm doing wrong to get the extra <li> at the beginning of any bullet lists i insert?

Any help would be gratefully received!

Thanks in advance all!
loki421 is offline   Reply With Quote
Old 07-17-2010, 06:11 PM   PM User | #2
Inigoesdr
Super Moderator


 
Inigoesdr's Avatar
 
Join Date: Mar 2007
Location: Florida, USA
Posts: 3,601
Thanks: 2
Thanked 397 Times in 390 Posts
Inigoesdr is a jewel in the roughInigoesdr is a jewel in the roughInigoesdr is a jewel in the rough
You've probably solved this by now, but if not: What did you mean by escape? If you want to remove it like your previous examples you would do this:
Code:
// these are not tested
txtVar = txtVar.replace(/<\/?li[^>]*>/gi, ""); // remove

txtVar = txtVar.replace(/<(\/?li[^>]*)>/gi, "&lt;$1&gt;"); // escape?
Inigoesdr is offline   Reply With Quote
Old 07-17-2010, 06:30 PM   PM User | #3
loki421
Regular Coder

 
Join Date: Feb 2009
Location: Worcester
Posts: 172
Thanks: 13
Thanked 6 Times in 6 Posts
loki421 is an unknown quantity at this point
Hi,

Yes, sorry, I did manage to work it out in the end. I wanted to remove the blank li tag, should have been a bit clearer I guess.

I used:
Code:
var txt:String = new String();
txt = richtexteditortxt.htmlText;
var pattern:RegExp = /<LI><\/LI>/g;
txt = txt.replace(pattern, "");
Think it's pretty much the same as you posted, but thanks anyway!

(Edited coz I'm an idiot )

Last edited by loki421; 07-17-2010 at 06:33 PM..
loki421 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:41 PM.


Advertisement
Log in to turn off these ads.