XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (611 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
13.68Mb size Format: txt, pdf, ePub

replace($input, “

([0-9]+)([A-Z]+)([0-9]+)$”, “$1-$2-$3”)

If you run this with the input string
23MAR2008
, the result will be
23-MAR-2008
. (Note the use of an anchored regex here to match and replace the entire string.)

If the
$
sign is followed by more than one digit, for example
($823)
, the system will try to locate the 823rd matching subexpression. If the regex doesn't contain that many subexpressions, it will assume that the
3
is an ordinary character and will look for the 82nd subexpression. If that still fails, it will look for the 8th subexpression. If that fails yet again, it will replace the
$8
by a zero-length string, so the final output will be
(23)
.

Other books

A Promise for Ellie by Lauraine Snelling
Eternity in Death by J. D. Robb
Frog Music by Emma Donoghue
The Girl Before Eve by Hobman, Lisa J
The Wild One by Danelle Harmon
The Battle Lord's Lady by Linda Mooney
Rescuing Lilly by Miller, Hallie
The End of Innocence by Allegra Jordan
Tigana by Guy Gavriel Kay