On Fri, Nov 19, 2010 at 3:22 PM, Eric <[email protected]> wrote:
> You might want to use [.] instead of \\. for the literal period,
I am not a regex expert - Is there any practical difference, or just a
matter of notation?
> or
> even
>
> /(?!index|test)[.]html$
There is a reason I put each URI separately, in code it looks like:
serveRegex("^((?!" +
"^/index\\.html$|" +
"^/test\\.html$" +
").)*$") ...
, this way it is easy to add/remove new URIs. It could be convenient
to write some regex string producer which would take varargs of URIs,
escape all special characters, and join them all using guava's Joiner.
More practical example, serve everything with some dispatcher servlet,
except /images/* and /resources/*
serveRegex("^((?!" +
"^/images/.+|" +
"^/resources/.+" +
").)*$") ...
But returning to your proposal, see code below:
Pattern p = Pattern.compile("^((?!^/index\\.html$|^/test\\.html$).)*$");
out.println(p.matcher("/").matches());
out.println(p.matcher("/foo.html").matches());
out.println(p.matcher("/index.html_foo").matches());
out.println(p.matcher("/index").matches());
out.println(p.matcher("/index.html").matches());
out.println(p.matcher("/test.html").matches());
It returns:
true
true
true
true
false
false
However after replacing regex with:
/(?!index|test)[.]html$
It returns 6 x false which is not desired behavior. :(
--
"Meaning is differential not referential"
kazik 'morisil' pogoda
http://www.xemantic.com/ http://blog.xemantic.com/
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-guice?hl=en.