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

RE: java Regex call

Subject: RE: java Regex call
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 10 Jul 2003 11:34:29 +0100
java regex date
> 
> Hi, Does anyone have an example of using the java.util.regex 
> functions to return the "components" of the regex that matched.

Since you are using Saxon 7.6, I would suggest using the XSLT 2.0/XPath
2.0 regex functionality, rather than calling the underlying Java
routines directly. It's quite tricky to call the Java methods because
they are "stateful" - they remember where the last match was, and move
on to the next one, which doesn't fit well with XSLT's side-effect-free
philosophy.

This one looks reasonably easy to do using xsl:analyze-string, but I'm
not sufficiently clear on what you're trying to do to actually provide
specimen code.

Michael Kay

> 
> Example: if my regex is defined as:-
> 
>  (([^_]*)_PARA)|((.*?)(PARA)(.*?))
> 
>  and my input is "ABC_PARA"
> 
>  Then I need to know what portions of the input matched
>  each (if any) part of the regex groups, ([^_]*) and (.*?) 
> etc,.  in terms of group number and matching string.
> 
>  Something like  "ABC" matched in group 4
> 
> I can use the following to find if I have a match, but can't 
> seem to get to the next stage...
> 
>   <xsl:for-each select="$rule//Type">  
>     <xsl:variable name="tdlType" select="."/>
>       <xsl:choose>
>         <xsl:when test="regex:matches($regex, $tdlType)">
>           <xsl:variable name="ruleName" select="$rule//@name"/>
>           <RULE_MATCH><xsl:value-of select="$ruleName"/></RULE_MATCH>
>           <xsl:copy-of select="$regex"/>
>         </xsl:when>
>         <xsl:otherwise/>
>       </xsl:choose>
>     </xsl:for-each>
> 
> Also, I'm using the Saxon 7.6  processor.
> 
> Thanks, John.
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.