Subject: Re: [xsl] How to escape the normal interpretation of parentheses when utilizing regex-group()? From: "Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 25 May 2023 12:39:13 -0000 |
Hi Roger, Please forgive me, I am so baffled. Maybe you need to show more. How are you using xsl:analyze-string. Whether you are capturing an xsl:matching-substring, an xsl:non-matching-substring, or both. The question as stated seems to presume a couple of things that I am not at all sure about.... Unless you find the problem has been solved, in which case please update us. p Regards, Wendell -----Original Message----- From: Roger L Costello costello@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Sent: Wednesday, May 24, 2023 7:01 AM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] How to escape the normal interpretation of parentheses when utilizing regex-group()? Hi Folks, My input consist of lines of text. Here is a sample input: 1 Record Type The XSLT program is to transform that line into this XML: <column>1</column> <field-name>Record Type</field-name> Here is another sample input: 2 thru 4 Customer/Area Code The XSLT program is to transform that line into this XML: <column>2 thru 4</column> <field-name>Customer/Area Code</field-name> I figured that <xsl:analyze-string and regex-group() would be suitable for breaking apart each line. What regex to use for column? The value of column is an integer followed optionally by "thru" and another integer. I figured this regex should do the job: ([0-9]+(\s+thru\s+[0-9]+)?) But, but, but, .... regex-group(1) means that whole regex. So with this input: 2 thru 4 Customer/Area Code regex-group(1) matches: 2 thru 4 Perfect. Unfortunately, regex-group(2) matches the inner, optional part. So I end up with this: <column>2 thru 4</column> <field-name> thru 4</field-name> Eek! Wrong. How to solve this problem? Is there a way to specify that the inner, optional part: (\s+thru\s+[0-9]+)? belongs only to regex-group(1), not to regex-group(2)? Stated another way, is there a way to indicate that the parentheses in the inner, optional part are not to be considered as regex-group() syntax? Stated still another way, is there a way to "escape" the normal interpretation of parentheses when utilizing regex-group()? /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] How to escape the normal , Bauman, Syd s.bauman | Thread | [xsl] [ANN] Balisage 2023 Program N, B Tommie Usdin btusd |
Re: [xsl] Tools to Flatten a DTD, Liam R. E. Quin liam | Date | Re: [xsl] Tools to Flatten a DTD, Peter Flynn peter@xx |
Month |