You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Xephyrus <xe...@xephyrus.com> on 2003/04/11 03:18:36 UTC

[string] count tag: set negation

Greetings again,


I'm trying to use the str:count tag to check for the negation of several
ranges of characters.  Basically I want to enforce that an input value is
alpha-numeric, so I want to know if there are any non-alpha-numeric
characters in the string.

I have tried using set=
  ^A-Za-z0-9
  ^A-Z^a-z^0-9
  ^ABCDEF...(snip)...xyz0123456789


Against a string of "x", all of these have returned a count of 1.  Does
the negation work?  If so, what is the quirk about how it works that I'm
missing?

Thanks for your help,
.  Topher



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Question about taglibs-i18n

Posted by Rex Hsu <Re...@foryou.com.tw>.
I got the first time to use the i18n taglibs, but I can't success.
The error message is "Can't find bundle for base name myRBTest, locale
zh_TW",

My "test.jsp " is,
----------------------------------------------------------------------------
-------------
<%@page contentType="text/html"%>

<html>
<head><title>TEST Page</title></head>
<body>
<%@taglib uri="/taglibs-i18n" prefix="i18n" %>

<i18n:bundle baseName="myRBTest" id="test">
    <i18n:message key="test.Hello"> Hello </i18n:message>
    <i18n:message key="test.World"/> World </i18n:message>
</i18n:bundle>

</body>
</html>
----------------------------------------------------------------------------
---------------

And my properties files are,
myRBTest.properties
-------------------------------
Hello=Hello
World=World

myRBTest_zh_TW.properties
-------------------------------
Hello=Foo
World=Bar

Anyone can help me ? Thanks in advance.
Rex Hsu



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: [string] count tag: set negation

Posted by Henri Yandell <ba...@generationjava.com>.
Yep. Basically the CharSet bits are designed to go as far as emulating a
regular expression's character class, ie) bits between a [..]. It's not
quite there yet though as you've found, ^ needing to be escaped and no
escaping for newlines etc [though that could be a JSP problem rather than
CharSet, depends if you tested it just with Commons Lang].

Hen

On Thu, 10 Apr 2003, Xephyrus wrote:

>
> To answer my own question:
>
>
> Yes, there is some quirkiness.  I looked at the code to try to figure out
> what was going on, and here's what I found:
>
> The str:count tag is just a wrapper around the Jakarta Lang
> CharSetUtils.count function, the simple one that takes a single set.  So,
> the str:count tag will _only_ allow you to use one set.  You cannot use
> more than one set in the same count tag.  I could not, for example, apply
> three different negation sets within the same tag.  No worky.
>
> Apparently, one set can be either a list of characters, or a range, both
> possibly negated.  You cannot have more than one range in one set.  If you
> do it seems that the first range is the only one considered.
>
> Additionally, it appears that if the set includes the caret '^' _anywhere_
> in it (not just in the first position), that set is negated.  It seems the
> caret can be escaped (ie '\^') to get a caret in the string.
>
> But, there is no way to put a tab, carriage return, line feed or any other
> non-printable character into the set.  Using notations like '\t', '\n',
> and '\r' actually seems to add 't', 'n' and 'r' to the set.
>
> I worked around the obstacle this all presented to me by using the regexp
> tag library instead.  It was more suited to what I was doing anyway.
>
> .  Topher
>
>
> >
> > Greetings again,
> >
> >
> > I'm trying to use the str:count tag to check for the negation of
> > several ranges of characters.  Basically I want to enforce that an
> > input value is alpha-numeric, so I want to know if there are any
> > non-alpha-numeric characters in the string.
> >
> > I have tried using set=
> >  ^A-Za-z0-9
> >  ^A-Z^a-z^0-9
> >  ^ABCDEF...(snip)...xyz0123456789
> >
> >
> > Against a string of "x", all of these have returned a count of 1.  Does
> > the negation work?  If so, what is the quirk about how it works that
> > I'm missing?
> >
> > Thanks for your help,
> > .  Topher
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org For
> > additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: [string] count tag: set negation

Posted by Xephyrus <xe...@xephyrus.com>.
To answer my own question:


Yes, there is some quirkiness.  I looked at the code to try to figure out
what was going on, and here's what I found:

The str:count tag is just a wrapper around the Jakarta Lang
CharSetUtils.count function, the simple one that takes a single set.  So,
the str:count tag will _only_ allow you to use one set.  You cannot use
more than one set in the same count tag.  I could not, for example, apply
three different negation sets within the same tag.  No worky.

Apparently, one set can be either a list of characters, or a range, both
possibly negated.  You cannot have more than one range in one set.  If you
do it seems that the first range is the only one considered.

Additionally, it appears that if the set includes the caret '^' _anywhere_
in it (not just in the first position), that set is negated.  It seems the
caret can be escaped (ie '\^') to get a caret in the string.

But, there is no way to put a tab, carriage return, line feed or any other
non-printable character into the set.  Using notations like '\t', '\n',
and '\r' actually seems to add 't', 'n' and 'r' to the set.

I worked around the obstacle this all presented to me by using the regexp
tag library instead.  It was more suited to what I was doing anyway.

.  Topher


>
> Greetings again,
>
>
> I'm trying to use the str:count tag to check for the negation of
> several ranges of characters.  Basically I want to enforce that an
> input value is alpha-numeric, so I want to know if there are any
> non-alpha-numeric characters in the string.
>
> I have tried using set=
>  ^A-Za-z0-9
>  ^A-Z^a-z^0-9
>  ^ABCDEF...(snip)...xyz0123456789
>
>
> Against a string of "x", all of these have returned a count of 1.  Does
> the negation work?  If so, what is the quirk about how it works that
> I'm missing?
>
> Thanks for your help,
> .  Topher
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org For
> additional commands, e-mail: taglibs-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org