You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "lutianxiang (JIRA)" <ji...@apache.org> on 2006/07/14 06:48:31 UTC

[jira] Created: (VALIDATOR-196) GenericValidator#matchRegexp

GenericValidator#matchRegexp
----------------------------

         Key: VALIDATOR-196
         URL: http://issues.apache.org/jira/browse/VALIDATOR-196
     Project: Commons Validator
        Type: Bug

    Versions: 1.3.1    
 Environment: Windows 2000 ; J2SDK 1.4.2 ; Eclipse 3.1.2
    Reporter: lutianxiang


GenericValidator.matchRegexp("as*&^%dfasd1314213","[a-zA-Z0-9]*");
User this method cannot get FALSE value

In this method Source like this...
.........
return matcher.match("/" + regexp + "/", value);

should be 
..........
return matcher.match("//" + regexp + "//", value);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


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


[jira] Commented: (VALIDATOR-196) GenericValidator#matchRegexp

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VALIDATOR-196?page=comments#action_12421107 ] 
            
Niall Pemberton commented on VALIDATOR-196:
-------------------------------------------

I don't think its the "/" characters you're missing - you need to put the start/end line boundary matchers (that is ^ and $) for ORO - otherwise it validates that "any of those characters are present" rather than "only those characters are present". Try the following:

GenericValidator.matchRegexp("as*&^%dfasd1314213","^[a-zA-Z0-9]*$"); 

As Gabriel said were planning to make the minimum dependency JDK 1.4 and use its built in regexp support and remove the ORO dependency. I had a look at doing this recently - it would be pretty straight forward except for one place in the EmailValidator that uses some perl specific syntax to remove comments:

http://jakarta.apache.org/commons/validator/xref/org/apache/commons/validator/EmailValidator.html#244

First I need to get my head round what exactly that is doing (I don't know perl) before working out how to replace it.

> GenericValidator#matchRegexp
> ----------------------------
>
>                 Key: VALIDATOR-196
>                 URL: http://issues.apache.org/jira/browse/VALIDATOR-196
>             Project: Commons Validator
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>         Environment: Windows 2000 ; J2SDK 1.4.2 ; Eclipse 3.1.2
>            Reporter: lutianxiang
>
> GenericValidator.matchRegexp("as*&^%dfasd1314213","[a-zA-Z0-9]*");
> User this method cannot get FALSE value
> In this method Source like this...
> .........
> return matcher.match("/" + regexp + "/", value);
> should be 
> ..........
> return matcher.match("//" + regexp + "//", value);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Commented: (VALIDATOR-196) GenericValidator#matchRegexp

Posted by "Gabriel Belingueres (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/VALIDATOR-196?page=comments#action_12421100 ] 
            
Gabriel Belingueres commented on VALIDATOR-196:
-----------------------------------------------

I think it is not a bug.

ORO Regexp require you to put a beginning and trailing slash to the expression:

GenericValidator.matchRegexp("as*&^%dfasd1314213","/[a-zA-Z0-9]*/")

I think the ORO dependency will be removed to Java 1.4 own regexp implementation instead, but I don't know when will be happening.

Gabriel

> GenericValidator#matchRegexp
> ----------------------------
>
>                 Key: VALIDATOR-196
>                 URL: http://issues.apache.org/jira/browse/VALIDATOR-196
>             Project: Commons Validator
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>         Environment: Windows 2000 ; J2SDK 1.4.2 ; Eclipse 3.1.2
>            Reporter: lutianxiang
>
> GenericValidator.matchRegexp("as*&^%dfasd1314213","[a-zA-Z0-9]*");
> User this method cannot get FALSE value
> In this method Source like this...
> .........
> return matcher.match("/" + regexp + "/", value);
> should be 
> ..........
> return matcher.match("//" + regexp + "//", value);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


[jira] Resolved: (VALIDATOR-196) GenericValidator#matchRegexp

Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/VALIDATOR-196?page=all ]

Henri Yandell resolved VALIDATOR-196.
-------------------------------------

    Resolution: Invalid

The only Perl in there is that you do "m/...../"  or the shorthand of "/...../".

I don't see any obvious reason as to why you would need to put "//" around the regexp and not just "/". Perl5Util's javadoc seems pretty clear that it's just the one "/".

The reporter's issue is INVALID. In regexp terms, "[a-zA-Z0-9]*" will always match the chosen text "as*&^%dfasd1314213". Ignoring the lack of ^ and $, having a single token followed by * will match anything, including an empty string as the * is zero-to-many and including a string of "%%%%". Niall's suggestion is probably what you're after, but it'll all depend on exactly what you want to do regexp-wise.

As it's the greatest computer book of all time, I heartily recommend Jeffrey Friedl's Mastering Regular Expressions book :)

> GenericValidator#matchRegexp
> ----------------------------
>
>                 Key: VALIDATOR-196
>                 URL: http://issues.apache.org/jira/browse/VALIDATOR-196
>             Project: Commons Validator
>          Issue Type: Bug
>    Affects Versions: 1.3.1
>         Environment: Windows 2000 ; J2SDK 1.4.2 ; Eclipse 3.1.2
>            Reporter: lutianxiang
>
> GenericValidator.matchRegexp("as*&^%dfasd1314213","[a-zA-Z0-9]*");
> User this method cannot get FALSE value
> In this method Source like this...
> .........
> return matcher.match("/" + regexp + "/", value);
> should be 
> ..........
> return matcher.match("//" + regexp + "//", value);

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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