[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

one for the regex gods

Subject: one for the regex gods
From: Ihe Onwuka <ihe.onwuka@xxxxxxxxx>
Date: Tue, 9 Jul 2013 00:05:26 +0100
 one for the regex gods
I have this regex

<!-- remove commas embedded in amounts-->
<!-- also replace multiple hyphens with asterisks -->
<xsl:variable name="line"
select="replace(replace(.,'-{2,}','**********'),'(,(\d{3})+(\D|$))','$2')"/>

operating on

Cash from Operatings/ Financial Expenses            372.43
4,889.48      -2,070.08         154.8

the role of the inner replace is to replace multiple hypens with
asterisks. In the above there are no multiple hypens so it should not
be effective.

the outer replace is meant to remove embedded commas in the field
however I noticed it is also causing me to lose the decimal point
which I of course would like to retain.

Upon diagnosis I tried

<xsl:variable name="line"
select="replace(replace(.,'-{2,}','**********'),'(,(\d{3}\.?)+(\D|$))','$2')"/>

and

<xsl:variable name="line"
select="replace(replace(.,'-{2,}','**********'),'(,(\d{3}[.]?)+(\D|$))','$2')"/>

various ways of slipping a decimal point into the captured variable
after the \d{3}

Neither had any effect.

So I thought I'd come ask.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.