Re: [xsl] xslt 2.0 regex and how to test it

Subject: Re: [xsl] xslt 2.0 regex and how to test it
From: Florent Georges <darkman_spam@xxxxxxxx>
Date: Sun, 19 Mar 2006 16:43:11 +0100 (CET)
Manfred Staudinger wrote:

> >     <xsl:value-of select="replace(., '\[[^\]]+\]', '')"/>

> Thanks for your solution, works perfect.
> Let me try to verbalize the regex (" for better readability):
> "\[[^\]]+\]"
> the string starts with "[" and ends with "]": SingleCharEsc
> "\[" and "\]"
> in between there is a charGroup: "[]"
> with a quantifier "+" for one or more occurrences
> the charGroup is a negcharGroup, as it starts with: "^"
> it contains one character "]": SingleCharEsc "\]",
> thus allowing for one or more characters which are not "]".

  Perfectly right (I mean, it's what I'd have said).

> I would prefer to try it out with an editor's find. To my
> surprise your solution worked fine with SciTE.

  Ok.  Regexps are supported in a lot of languages and tools.  But with
some differences and/or enhancements.  Emacs for example have a tool
that helps to build regexps: re-builder.  Maybe your editor have such a
functionality.  If you are aware of these differences, it can be a good
way to design a complex regexp.  But it's not the way to learn a
specific regexps language in particular, IMHO (here XPath 2.0 regexps).

  If you don't want to write each time an XSLT script and a input
document to test one regexp, you can write an extension to your
favorite editor.  In Emacs, this could be done quite easily, I think. 
Or a specific client for your XSLT processor (for example a Java client
for Saxon, taking a regexp and a text to test matching, and building a
simple script from these).

> One difference I noted was, that SciTE does not need
> the SingleCharEsc within the charGroup.

  It's the way traditional regexps work.  I must confess it's what I
tried first.  But Saxon gave me the right advice to escape it.  A good
thing IMHO, more rigorous.

  Regards,

--drkm



	

	
		
___________________________________________________________________________ 
Nouveau : tiliphonez moins cher avec Yahoo! Messenger ! Dicouvez les tarifs exceptionnels pour appeler la France et l'international.
Tilichargez sur http://fr.messenger.yahoo.com

Current Thread