gmaynard
|
Posted: May 11, 2011 02:03 by gmaynard
|
|
(The site finally let me create an account...) While reviewing someone else's patch (for running on Android), I was trying to parse out the regex here: private static final Pattern BOSH_START = Pattern.compile("<" + "(? ?:[^:\t\n\r >]+ |(?:\\{[^\\}>]*?}))?"+ "body" + "(?:[\t\n\r ][^>]*?)?" + "(/>|>)"); The part I'm not following is: (?:\\{[^\\}>]*?}) This causes it to match <\{text}body>. I wondered if it was some obscure XML syntax that I hadn't seen, but it doesn't look like it. Remember what that bit is for? |
ComposableBody.BOSH_START
Replies: 3 - Last Post: May 18, 2011 20:03
by: Mike Cumings
by: Mike Cumings
showing 1 - 4 of 4
Mike Cumings
|
Posted: May 18, 2011 20:03 by Mike Cumings
|
|
I can't recall why that particular subexpression was used. I think I may have pulled it in thinking that the local XSI type specification format used in schemas was part of the XML namespace spec. Reading through the namespace spec, this is obviously not the case. I've yanked the subexpression in question from the code in trunk and have also escaped the final closing brace. As an aside, the regex-based parsing is currently only used within the tests. I'll probably be pulling it out into a test lib sometime in the future to clean this up further. Thanks for the feedback! |
gmaynard
|
Posted: May 13, 2011 20:42 by gmaynard
|
FYI, to make this expression compile on the Pattern package Android uses, the final } must be escaped:
- Pattern.compile("<" + "(?:(?:[^:\t\n\r >]+:)|(?:\\{[^\\}>]*?}))?"
+ Pattern.compile("<" + "(?:(?:[^:\t\n\r >]+:)|(?:\\{[^\\}>]*?\\}))?"
I'd still like to know what that subgroup is for... |
Replies: 3 - Last Post: May 18, 2011 20:03
by: Mike Cumings
by: Mike Cumings

?:[^:\t\n\r >]+
|(?:\\{[^\\}>]*?}))?"





