Skip to content

Instantly share code, notes, and snippets.

View longzheng's full-sized avatar

Long Zheng longzheng

  • Melbourne, Australia
  • 20:17 (UTC +10:00)
  • X @longzheng
View GitHub Profile
@longzheng
longzheng / gist:1513173
Created December 23, 2011 04:48
Difference in regex quantifiers parsing of JAVA and .NET
So I discovered this interesting difference in how JAVA and .NET parses Regex quantifiers by throwing myself against a brick wall (Twitter's regex library https://github.com/twitter/twitter-text-java/blob/master/src/com/twitter/Regex.java)
In JAVA, if you do
[[a-z]\-]*
It would actually match zero or more of "a-z" AND "-". It seems to automatically include everything inside any child square brackets.
In .NET,
[[a-z]\-]*
Only matches zero or more of "-". Just one of [a-z]
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">
<App xmlns="" BitsPerPixel="32" ...
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">
<App xmlns="" BitsPerPixel="32" ...
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">
<App xmlns="" BitsPerPixel="32" ...
<IconPath ...