This discussion is archived
4 Replies Latest reply: Mar 6, 2013 5:50 AM by Murray9654 RSS

help on regex?

Murray9654 Newbie
Currently Being Moderated
Hi I am trying to create a regular expression which will be of 6 characters long and out of 6 characters there should be at least one caps (could be more). how to create a regex for this?
  • 1. Re: help on regex?
    gimbal2 Guru
    Currently Being Moderated
    Muralidhar wrote:
    how to create a regex for this?
    Its pretty basic. So in your case - you need to learn regex. This is what thought me regex - it is very old and written for PHP, but it is universally applicable and quite clearly written:

    http://www.phpbuilder.com/columns/dario19990616.php3

    The Oracle docs are also quite useful if you want a more java-oriented source of information:

    http://docs.oracle.com/javase/tutorial/essential/regex/
  • 2. Re: help on regex?
    Murray9654 Newbie
    Currently Being Moderated
    I have done some basic work but unable to find the solution. The problem is in 6 characters there should be one caps at least and it can be anywhere in the string. can anyone help me in this?
  • 3. Re: help on regex?
    Murray9654 Newbie
    Currently Being Moderated
    Hi I have found some example which satisfies my requirement. That is
    (?=.*[A-Z]).{6}
    but i am facing little bit difficult in understanding this. If i remove "?=" from the regex
    (.*[A-Z]).{6}
    the entire meaning changes. when i look at the "Pattern" doc it says something about " via zero-width positive lookahead" but what is the meaning of this? how this works? I have spent some time in google but no use. There is no any good doc which explains this. can any one help me understanding this.
  • 4. Re: help on regex?
    Murray9654 Newbie
    Currently Being Moderated
    any help?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points