Problem creating a regular expression

Hi Everyone
I am trying to create a regular expression for validating a password string for the following given rule -
It must contain atleast any two of following 4 classes of characters -
1. lowercase letters.. a - z
2. uppercase letters.. A - Z
3. digits.. 0 - 9
4. Special characters.. !@#$%^&*()/?><
I m having a hard time creating such regular expression. I will really appreciate if someone can help me with this.

[http://google.com/search?q=regular+expression+password+validation+site:forums.sun.com]

Similar Messages

  • Problem in creating a Regular Expression with gnu

    Hi All,
    iam trying to create a regular expression using gnu package api..
    gnu.regex.RE;
    i need to validate the browser's(MSIE) userAgent through my regular expression
    userAgent is like :First one ==> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
    i wrote an regular expression like this:
    Mozilla.*(.*)\\s*(.*)compatible;\\s*MSIE(.*)\\s*(.*)([0-9]\\.[0-9])(.*);\\s*(.*)Windows(.*)\\s*NT(.*)\\s*5.0(.*)
    Actaully this is validating my userAgent and returns true, my problem is, it is returning true if userAgent is having more words at the end after Windows NT 5.0 like Second One ==> Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Testing
    i want the regularExpression pattern to validate the First one and return true for it, and has to return false for the Second one..
    my code is:
    import gnu.regexp.*;
    import gnu.regexp.REException;
    public class TestRegexp
    public static boolean getUserAgentDetails(String userAgent)
         boolean isvalid = false;
         RE regexp = new RE("Mozilla.*(.*)\\s*(.*)compatible;\\s*MSIE(.*)\\s*(.*)([0-9]\\.[0-9])(.*);\\s*(.*)Windows(.*)\\s*NT(.*)\\s*5.0(.*)");
         isvalid = regexp.isMatch(userAgent);
         return isvalid;
    public static void main(String a[])
         String userAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
         boolean regoutput = getUserAgentDetails(userAgent);
         System.out.println("***** regoutput is ****** " + regoutput);
    }please help me in solving this..
    Thanks in Advance..
    thanx,
    krishna

    Ofcourse, i can do comparision with simple string matching..
    but problem is the userAgent that i want to support is for all the MSIE versions ranging from 5.0 onwards, so there will the version difference of IE like MSIE 6.0..! or MSIE 5.5 some thing like that..
    any ways i will try with StringTokenizer once..!
    seems that will do my work..
    Thanks,
    krishna

  • Problems with java regular expressions

    Hi everybody,
    Could someone please help me sort out an issue with Java regular expressions? I have been using regular expressions in Python for years and I cannot figure out how to do what I am trying to do in Java.
    For example, I have this code in java:
    import java.util.regex.*;
    String text = "abc";
              Pattern p = Pattern.compile("(a)b(c)");
              Matcher m = p.matcher(text);
    if (m.matches())
                   int count = m.groupCount();
                   System.out.println("Groups found " + String.valueOf(count) );
                   for (int i = 0; i < count; i++)
                        System.out.println("group " + String.valueOf(i) + " " + m.group(i));
    My expectation is that group 0 would capture "abc", group 1 - "a" and group 2 - "c". Yet, I I get this:
    Groups found 2
    group 0 abc
    group 1 a
    I have tried other patterns and input text but the issue remains the same: no matter what, I cannot capture any paranthesized expression found in the pattern except for the first one. I tried the same example with Jakarta Regexp 1.5 and that works without any problems, I get what I expect.
    I am using Java 1.5.0 on Mac OS X 10.4.
    Thank to all who can help.

    paulcw wrote:
    If the group count is X, then there are X plus one groups to go through: 0 for the whole match, then 1 through X for the individual groups.It does seem confusing that the designers chose to exclude the zero-group from group count, but the documentation is clear.
    Matcher.groupCount():
    Group zero denotes the entire pattern by convention. It is not included in this count.

  • Problem with email regular expression

    I found the following regular expression from this website : http://www.regular-expressions.info/email.html
    \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\bor
    ^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$I am using the following website to check its success, as well as my java app. : http://www.regexplanet.com/simple/index.html
    of course java has a problem with the illegal escape character so i add another "/".
    In both of my testing scenarios the regex value seems to fail. Am I missing something here?
    If anyone could also test this regex and verify or correct my problem I would be very grateful.
    Edited by: rico16135 on Jun 5, 2010 4:01 PM
    Edited by: rico16135 on Jun 5, 2010 4:02 PM

    rico16135 wrote:
    of course java has a problem with the illegal escape character so i add another "/".I seem to be missing the distinction between a forward slash / which is not an escape character, and a backslash \ which is.
    Also, if you show your actual Java code (in code tags, of course), and describe clearly and precisely what's going wrong--pasting in the exact, complete error message and indicating clearly which line caused it, if there is one--people will be in a better position to help you.

  • Problem with java regular expression

    Hi,
    I try to use the regular expression as follows
    Pattern pattern = Pattern.compile("\wpub\w");
    Matcher matcher = null;
    matcher = pattern.matcher("38712pubeeqpwoiu");
    if (matcher.matches())
    System.out.println("Matched");
    else
    System.out.println("Not Matched");
    and I always get the answer as "Not Matched". I am not sure what is wrong with the code.
    thanks

    Use find() rather than matches().

  • Problem with a regular expression

    I want to check the date.
    I wrote a sample pattern
    pattern = Pattern.compile("([0-9]{2}\\.[0-9]{2}\\.[0-9]{2,4}){0,10}");DD.MM.YYYY
    DD.MM.YY
    "" - empty date
    It works fine, but how could I check, whether the date is not greater than 31 and so on with the other things.
    It should pass:
    "11.12.2006"
    "15.15.2005" - wrong date
    "01.00.2005" - worng date
    "22.22.1000" - also could be wrong.
    Thanks in advance.

    CalendarI check befor the data will be sent to the database.Good. I just meant that regex can't check whether Febuary has 28 or 30 days in a giant leap year.
    There is not only dates, special fields like names,
    ids and so on. I check all with regular expressions,
    wanted the date also. And wanted to know whether it
    is possible in this expression to make so, that the
    date can be "". I can check it explicitly, I wanted
    to do all the job with a regex.Why not simply check for a String length of 0? :)
    The first sample I wrote allows
    "DD.MM.YYYY" and "" and "DD.MM.YY", but in last
    sample "" and YY impossibleHm? You mean two-digit year and no year (but the rest of date still present)?

  • Problem with my regular expression

    Hi
    I am trying to find function declarations within source code. I've been trying to use regular expressions, but if anyone else has an easier / better way to do this, as ross perot said, "I'm all ears"
    Here's my regular expression printed out:
    sb = [.]*void foo[.]*
    sb is a stringbuffer variable, so the regex is [.]*void foo[.]*
    Can anyone tell me why when I run this pattern on my loaded source file it tells me that the pattern does not match? LOL can you help me fix this?

    I doubt that regex is a very good way to find method
    declarations, although you can probably make it work
    reasonably well for the most common cases.You've got a point. This is just to get the ball rolling. I don't want to have to do full syntax parsing yet.
    >
    In your particular situation, I'd guess it has to do
    with [.]*. I think that inside [], the
    dot is a literal dot, not "any character." If you
    want "zero or more of anything followed by void" then
    it's .*void.
    Just tried
    sb = .*void foo.*
    it still didn't work.
    In any case, however, this only covers methods
    returning void. For the more general case, I don'tI didn't give you all my code. I actually use a classloader and reflection to determine what the methods are, return values etc. So yes, void in this case is not overly flexible, but I can plug in whatever it is I'm looking for.
    think a simple regex will do it. You need a kind of
    tool that I can't recall the name of--something to
    build and examine an abstract syntax tree perhaps.
    Try starting here:
    http://www.google.com/search?q=java+abstract+syn
    tax+treeI'm not even sure it abstract syntax tree is what you
    want, but I think it's at least closer than regex.
    There might be something that's a step or two earlier
    in the compilation process that will give you what
    you want.

  • Is there a way to be sure that created Regular expression (Class RegExp) is valid?

    Is it possible to create wrong Regular expression in  ActionScript/Flex which will cause runtime error? Or how to validate RegExp?
    I've tried so many  weird regexpes in Flash and Flex, it never complained! How do I know If my  regexp valid?

    "It is VERY reliable. If match() returns null - this means that String doesn't have any parts that match pattern."
    Exactly, but is doenst mean that syntax of RegExp is correct since you dont know what gave you null
    Apparemtly /foo([/ is wrong expression, and Java compiller complains:
    Unclosed character class near index 4 foo([     ^
    but in AS3 i can create
    var xxd:RegExp = /foo([/;
    when I do xxd.exec("") it got null;
    and no complains!! How to understand that?
    But in same time
    var xxd:RegExp = /foo/;
    xxd.exec(""), will be null as well!?

  • Regular Expressions and Numbers in Strings

    Looking for someone who has had experience in using Regular Expressions in the Classification Rule Builder.
    We have an eVar that is collecting the number of search results in this fashion:
    <Total Results>_<# of Item 1>_<# of Item 2>_<# of Item 3>_<# of Item 4>
    Example output would look like this:
    150_50_0_25_75
    What we've done is initially create a Regular Expression that looks like this:
    ^(.+)\_(.+)\_(.+)\_(.+)\_(.+)$
    The problem is, it appears in situations where the output contains a zero in one of the slots, the value is ignored and it receives the value in the next place over.  Using the example output shown above, I would end up with values like this:
    $0 150_50_0_25_75
    $1 150
    $2 50
    $3 25
    $4 75
    $5 {null}
    Here's the weird part.  When I perform a test of a single record, it appears like it will work just fine, but when it actually runs in Omniture, it's not working as expected.  Here's something else I'd like to know if it's possible to address.  The five-place string is only the newest iteration of this approach.  In the past, we started out with a two-place version, then three-place and then four.  Any recommendations for handling all scenarios?
    Any and all advice is welcome.  Thanks in advance!

    Doing some playing around on rubular.com and thinking the Regular Expression should be build this way instead:
    ^(\d+)\_(\d+)\_(\d+)\_(\d+)\_(\d+)$
    Again, still looking for any additional guidance from more experienced individuals.  Thanks!

  • Regular Expressions - unsetting greedy possible?

    Hi,
    I'm currently working on a parser and got some problems with the regular expressions in ABAP.
    Lets say I want to calculate (22)*(33).
    The RegExp \(.+\) finds everything between brackets - the problem is, that the engine finds everything between the first opening and the last closing bracket (actually it should find the first opening and the first closing bracket).
    Is there a way to tell the engine to work ungreedy?
    Thanks for your help
    Chris

    Hi Prashant,
    unfortunately this won't work either.
    I'd better give some more information on the topic to increase understanding.
    In order to calculate this string mathmatically I created a function working recursively. It calculates the (math)value of a string.
    So lets say we want to calculate (22)*(33), the function is supposed to work this way:
    math ( "(22)*(33)")
    -> math ("2+2") (Calculating and returning value: 4)
    The formula now is "4*(3+3)"
    -> math("3+3") (Calculating and returning value: 6)
    The formula now is "4*6"
    -> math("4*6") (calculating and returning value 24)
    Thus ABAP does not know ungreedy searches in regular expressions, the function would work this way:
    math ( "(22)*(33)")
    ->math( "22)*(33" ) (using the wrong brackets...)
    ... leading to a math error.
    Your solution, Prashant, would work for the first recursive call. Then, the formula would be "(22)*(32)" again.
    Thanks though
    Regards
    Christian

  • Requirements gateway & regular expressions

    I'm trying to create a regular expression that will match a Requirement ID type in a MS Word document using Requirements Gateway.
    Our syntax for a Requirement ID is as follows:
        '* shall [::requirement id] *'
    An example would be
        'The system shall [::requirement1] self destruct after 1 minute of use.'
    I'm using the following RE.
        shall[ \t]*\[[ \t]*(.*):.+)\]
    I've been able to get it to match 'most' of Requirement ID's ,but a few aren't caught...most noteably those Requirement ID's that run past the end of the
    line.
    When 'shall' is on one line and '[::requirement1]' is on the next, the Requirement ID isn't matched.
    Are there any limitations to the RE engine that Requirements Gateway uses?
    If not, any help with the RE would be MUCH appreciated.
    thanks
    Pat

    Allen,
    Thanks for the advice.  Unfortunately it didn't help
    Again, our requirements are identified by a 'shall' followed by a tag in brackets. 
    Ie  The unit shall [<optional source>::requirement id] be expensive.
    The RE, "shall\[(.*):.+)\]" doesn't always work. (Sorry for the embedded emoticon)
    Most of the time it identifies the tag but says
    Requirement ' : XYZ' can't be covered.
    Error: Requirement defined several times
    Other times is combines two tags into one.
    I'm attaching the modifed type and the doc thats causing the problems.
    Thanks for your continued help,
    Pat

  • Regular Expression for multiple emails

    Hi! I have a jsp page that has an inputTextArea so the user can enter multiple email addresses. In the backing bean (after they submit) I tokenize thru it and add email addresses to an arraylist. I want to validate that they are correct format before adding to arraylist, but how do I do that in the backing bean? All regular expression examples I have seen are in jsp page and javascript. Any sample code / suggestions would be greatly appreciated - as I have not had much experience with regular expressions. Thanks!

    Hi,
    this could be a solution for your problem; I've created two regular expressions to find valid email- and http-addresses in fulltext or xml-text fields ;-)
    HTTP:
    (\\s|>|^)(?!(@|/|\\.))(http://|https://|ftp://|sftp://|www\\.)([A-Za-z0-9_-]{2,}\\.)+[A-Za-z]{2,4}[:]?(/|\\?|\\&|\\;|\\%|=|\\.|\\#|_|-|[A-Za-z0-9])*(?!(@))(?<=([A-Za-z0-9=]+))(\\s|\\W|_|<|$)
    eMail:
    (\\s|>|^)(?!(:|www\\.|\\.))[A-Za-z0-9_.-]+@([A-Za-z0-9_-]+\\.)+[A-Za-z]{2,4}(\\s|\\W|_|<|$)
    sincerely
    Hans Georg Filipp

  • Regular expression not working for adobe forms

    Hi,
    Iam using qtp for adobe forms and for some reason if i put in regular expression for apid value it doesn't recognise the object..there is nothing wrong with the regular expression as it is evaluated using regular expression evaluator in qtp 11.0....any ideas
    I got all the addins and everything and when i used regular expression for the top window it works but for any other object it doesn't

    Please try the code and see the problem. The regular expression is fine.
    I can replace the string with these and got results like this:
    import java.util.regex.Pattern;
    public class HtmlFilter implements TextFilter {
        private static String strTagPattern = "<\\s?(.|\n)*?\\s?>";
        private static int patternMode = Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.CANON_EQ;
        private static Pattern tagPattern = Pattern.compile(strTagPattern, patternMode);
        public String filter(String t) {
              if(t==null || t.length()==0) return "";
            String ret = null;
            return tagPattern.matcher(t).replaceAll("");
         public static void main(String[] args) {
              System.out.println(new HtmlFilter().filter(null));
              System.out.println(new HtmlFilter().filter(""));
              System.out.println(new HtmlFilter().filter("<P>abc def</P>"));
              System.out.println(new HtmlFilter().filter("<P>&#25105;&#22269;&#30707;&#27833;&#20379;&#24212;&#23433;&#20840;&#31995;&#32479;&#24433;&#21709;</P>"));
    }The results are
    abc def
    ????????????

  • Regular Expressions with Call Policy on VCSe

    Hi Guys,
      I am working on firming up the call policy on my VCS Expressway to try to better intercept the SIP spam requests it is getting from internet ip numbers. Right now those spam requets are getting rejected by the loop detection but I want to intercept them before they even do a search on the Expressway. It seems that the call policy rules I create without regular expressions are functioning fine but I don't think I have the syntax correct for the regular expressions.
    The goal of this rule is to reject any incoming SIP request that has a destination alias format of 7 to 17 digits followed by an @VCSe_IP. so for example it would reject the following attempts: 0123456@VCSe_IP and 0123456789101112@VCSe_IP with one rule.
    The policy I created is this: source pattern: unauthenticated user, Destination pattern: \d{7,17}@xx\.xx\.xx\.xx (where xx is the individual octets of the VCSe IP address), Action: reject  
    However the above policy does not seem to be rejecting the calls before they do a search. I have checked the above expression with the check pattern tool on the VCSe and it comes up with a sucessful match when I try the destination alias of a request that made it through, hence my confusion. Any help you guys could provide would be appreciated.
    Thanks,
    Steven                

    Steven,
    Default Zone access rules do not relate to this at all and you can keep those set to 'No'.
    How exactly are you placing the test calls when attempting to verify this?
    I created the following CPL rule on my X7 VCS (With 10.10.10.10 being the IP address of my VCS):
    Source pattern:
    Destination pattern: \d{7,17}@10\.10\.10\.10
    Action: Reject
    I then proceeded with placing a SIP call from an unregistered C20, calling the URI '[email protected]' while running a diagnostics log on my VCS with Network log level set to 'DEBUG', and captured the following in that log:
    Incoming INVITE:
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,598" Module="network.sip" Level="INFO":  Src-ip="10.x.x.x"  Src-port="5060"   Detail="Receive Request Method=INVITE, Request-URI=sip:[email protected], Call-ID=9dd19ad75b1063ecf716461b149e9e2a"
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,598" Module="network.sip" Level="DEBUG":  Src-ip="10.x.x.x"  Src-port="5060"
    SIPMSG:
    |INVITE sip:[email protected] SIP/2.0
    Call processing logic, showing CPL matching:
    2013-02-22T16:03:36+01:00 vcs02 tvcs: Event="Search Attempted" Service="SIP" Src-alias-type="SIP" Src-alias="10.x.x.x" Dst-alias-type="SIP" Dst-alias="sip:[email protected]" Call-serial-number="0886391c-7d01-11e2-adf5-0050569a08fd" Tag="08863aac-7d01-11e2-bd2e-0050569a08fd" Detail="searchtype:INVITE" Level="1" UTCTime="2013-02-22 15:03:36,601"
    2013-02-22T16:03:36+01:00 vcs02 tvcs: Event="Call Attempted" Service="SIP" Src-ip="10.x.x.x" Src-port="5060" Src-alias-type="SIP" Src-alias="sip:10.x.x.x" Dst-alias-type="SIP" Dst-alias="sip:[email protected]" Call-serial-number="0886391c-7d01-11e2-adf5-0050569a08fd" Tag="08863aac-7d01-11e2-bd2e-0050569a08fd" Protocol="UDP" Auth="NO" Level="1" UTCTime="2013-02-22 15:03:36,601"
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,602" Module="network.cpl" Level="DEBUG":  Remote-ip="10.x.x.x"  Remote-port="5060"   Detail="CPL: "
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,602" Module="network.cpl" Level="DEBUG":  Remote-ip="10.x.x.x"  Remote-port="5060"   Detail="CPL:   "
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,602" Module="network.cpl" Level="DEBUG":  Remote-ip="10.x.x.x"  Remote-port="5060"   Detail="CPL: matched "
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,602" Module="network.cpl" Level="DEBUG":  Remote-ip="10.x.x.x"  Remote-port="5060"   Detail="CPL: "
    VCS responds to INVITE with 403 Forbidden:
    2013-02-22T16:03:36+01:00 vcs02 tvcs: UTCTime="2013-02-22 15:03:36,616" Module="network.sip" Level="DEBUG":  Dst-ip="10.x.x.x"  Dst-port="5060"
    SIPMSG:
    |SIP/2.0 403 Forbidden
    As you can see, on my VCS everything seems to work as expected. I'd recommend you capture a similar diagnostics log on your own VCS to check what is different in your test call compared to the output above.

  • Regular Expressions on strings

    How would I go about creating a regular expression in LabVIEW that, say, takes an input of a list of numbers (1, 2, 3, 4, 5) and turns it into an array with the elements [1, 2, 3, 4, 5]? If someone could show me example code, I would be quite grateful.
    Thanks.
    Using LabVIEW 2009 on Windows Vista

    Spreadsheet String to Array should work for conversion to strings or numbers...
    Richard
    Attachments:
    stringarr.gif ‏18 KB

Maybe you are looking for