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

Re: one for the regex gods

Subject: Re: one for the regex gods
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Tue, 09 Jul 2013 01:35:27 +0200
Re:  one for the regex gods
On 09.07.2013 01:05, Ihe Onwuka wrote:
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')"/>

Have you considered using '$2$3' as the outer replacement?


But Ibm wondering whether the regex is really intended as it is written here. If you are trying to replace repeating groups of (,(\d{3})) with each $2, it should be more like (,(\d{3}))+ instead of (,(\d{3})+b&)

You canbt, however, refer to repeated occurrences of a captured substring. $2 will give you only the last, iirc.

If there were lookaheads in XPath 2, it might be feasible for repeated ,\d{3} groups.

Maybe you should just tokenize or xsl:analyze-string your lines on a tab, determine whether a given token represents a number and if it does, strip all commas. Then reassemble the line if needed.

Gerrit

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.