 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 27th, 2009, 02:52 PM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
|
|
Need to build regex to find specific hex characters
Hi,
I have a statement: <xsl:analyze-string select="$cmdSyntax" regex="^([A-Z0-9]+)-.*$">
that I need to adjust.
Rather than just looking for the dash after the alpha numerics, I need to search for a specific string of hex characters (xE2, x80 then x91). They will all three be there for the targets I'm looking for.
I'm not seeing how to build a regex that locates specific hex values.
Can you help?
Thanks,
- mike
__________________
------------------------
Keep Moving Forward
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare
|
|

July 27th, 2009, 03:19 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
I think hex characters are referred to as "â" etc. Try that see if it works.
|
|

July 27th, 2009, 03:43 PM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
|
|
Sounds logical, but doesn't seem to work.
My expression became: <xsl:analyze-string select="." regex="^([A-Z0-9]+)â.*$">, but I'm still not getting a hit.
I did notice that the expression \xnn where nn is a hex value is strictly disallowed by the definition and the interpreter should reject the use of such a construct.
Too bad, \xE2 is just what I was looking for.
Appreciate the effort though.
__________________
------------------------
Keep Moving Forward
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare
|
|

July 27th, 2009, 04:23 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
Could you show a sample of your XML?
I'm confused as to whether it contains something like
Code:
<element>E2</element>
or something like
Code:
<element>â</element>
In the first case the regex to match it is 'E2', in the second case it is 'â'
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

July 27th, 2009, 04:37 PM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
|
|
Here's the XML:
Code:
<Syntax>SET‑ATTR‑EQPT:[<TID>]:<AID>:<CTAG>::[<NTFCNCDE>],<CONDTYPE>,[<LOCN>],[<DIRN>],,[<SRVEFF>];</Syntax>
In this example, the dashes between SET and ATTR and between ATTR and EQPT are not real dashes (0x2D), but are a secret code embedded when Adobe Framemaker exported an Escaped-Hyphen-H character sequence into XML. ESC-Hyphen-H is something Framemaker uses to create hyphens that don't cause line wraps. In a long line, Framemaker will attempt to line wrap at a dash if one exists in the line. So people use ESC-Hyphen-H to inform Framemaker to wrap at the 80th character, not arbitrily at a dash. The secret code is 0xE2 0x80 0x91, at least that what my hex editor shows the file to contain.
Thanks,
- mike
__________________
------------------------
Keep Moving Forward
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare
Last edited by mphare; July 27th, 2009 at 04:39 PM..
|
|

July 27th, 2009, 04:53 PM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
I suspect your hex editor is showing you the UTF-8 encoding of the Unicode character. I suspect the real Unicode character is a non-breaking-hyphen, code x2011 - I haven't actually checked that E28091 is the UTF-8 encoding of x2011, but I suspect it is. If that's the case then the regex you need is '‑'
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|
The Following User Says Thank You to mhkay For This Useful Post:
|
|
|

July 27th, 2009, 05:03 PM
|
|
Friend of Wrox
|
|
Join Date: May 2004
Posts: 109
Thanks: 18
Thanked 0 Times in 0 Posts
|
|
That was it. ‑ works as expected.
Thank you!
__________________
------------------------
Keep Moving Forward
GnuPG Key fingerprint = 1AD4 726D E359 A31D 05BF ACE5 CA93 7AD5 D8E3 A876
Michael Hare
|
|
 |