Regular Expressions

Questions, tips and tricks and techniques for scripting in Servoy

Regular Expressions

Postby Providence1 » Tue Jun 30, 2009 11:43 pm

Getting some interesting results, as you can see in the attached pictures, with the following html that does not seem to render properly in the Sun's render engine:
Code: Select all
<o:p></o:p>
<st1:PostalCode w:st="on">33178</st1:PostalCode>


Trying to use variations of the following regular expression to get rid of <o:p></o:p> and <st1> it but can't seem to at this point:

Code: Select all
globals.gEmail_Body = utils.stringReplace(globals.gEmail_Body, "</o:", "</");
globals.gEmail_Body = globals.gEmail_Body.replace(/<st1:(.)>/gim ,"<span>");


Any help would be most appreciated!!!
Attachments
Picture 1062.png
Picture 1062.png (11.06 KiB) Viewed 3451 times
Picture 1061.png
Picture 1061.png (7.81 KiB) Viewed 3450 times
Providence
Providence1
 
Posts: 456
Joined: Tue Aug 17, 2004 2:36 am
Location: New York, NY

Re: Regular Expressions

Postby ptalbot » Wed Jul 01, 2009 12:35 am

The following works for me:
Code: Select all
globals.gEmail_Body = globals.gEmail_Body.replace(/<o:p>/gi ,"<p>").replace(/<\/o:p>/gi ,"</p>");
globals.gEmail_Body = globals.gEmail_Body.replace(/<st1:[^>]*>/gi ,"<span>");
globals.gEmail_Body = globals.gEmail_Body.replace(/<\/st1:[^>]*>/gi ,"</span>");


You can chain replace method as much as you want...

As for the "Sun's render engine", this is the single worst piece of crap in the whole Swing API, the culprit's real name is javax.swing.text.html.HTMLEditorKit.

So yes, you can blame Sun (Oracle?) for that, because every living implementation of a html editor in Java suffers from its numerous bugs, and it has never been properly fixed!
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Regular Expressions

Postby Thomas Parry » Wed Jul 01, 2009 4:05 am

Tom Parry
Prospect IT
Java/C++/Servoy/Jasper Reports/Simulation/Service Applications
http://www.prospect-saas.biz
Thomas Parry
 
Posts: 498
Joined: Thu Jan 10, 2008 8:48 pm
Location: Ottawa, Canada

Re: Regular Expressions

Postby ptalbot » Wed Jul 01, 2009 6:13 am

Quite right Tom!

But it only handles the rendering part, not the editing part...
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: Regular Expressions

Postby Harjo » Wed Jul 01, 2009 1:07 pm

Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Re: Regular Expressions

Postby patrick » Wed Jul 01, 2009 2:16 pm

Harjo, you are realling watching this closely, aren't you :-)
Patrick Ruhsert
Servoy DACH
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Re: Regular Expressions

Postby Harjo » Wed Jul 01, 2009 2:31 pm

yes, thanks to google Alerts ;-)
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 39 guests

cron