Regular Expression help

Discussion in 'Perl Misc' started by asadikhan@gmail.com, Jul 18, 2005.

  1. Guest

    Hi,

    I want to create a regular expression. I have come up with something
    like this:

    Scan*ValRel(QualValRel)*

    which basically means that I should see:

    zero or more of "Scan"
    exactly one of "Val"
    exactly one of "Rel"
    zero or more of "ScanValRel"

    however I can't seem to get this right. I used Expresso as well to try
    to come up with the right expression. The closest I got was:

    (Scan)*(Val)(Rel)(QualValRel)*

    but this allows

    ScanValValRel (as it finds ValRel as part of this string). I don't want
    it to do that.

    As specified above, I want to find exactly one of Val (no more) etc.

    How do I do this?
    , Jul 18, 2005
    #1
    1. Advertising

  2. Guest

    wrote:
    > Hi,
    >
    > I want to create a regular expression. I have come up with something
    > like this:


    snip

    > (Scan)*(Val)(Rel)(QualValRel)*


    you probably want to learn more about ^ and $ or other anchors
    (beginning of word for example)

    Jan
    , Jul 19, 2005
    #2
    1. Advertising

  3. Big and Blue Guest

    wrote:
    >
    > I want to create a regular expression. I have come up with something
    > like this:
    >
    > Scan*ValRel(QualValRel)*
    >
    > which basically means that I should see:
    >
    > zero or more of "Scan"


    No. Sca followed by any number of n.

    > exactly one of "Val"
    > exactly one of "Rel"
    > zero or more of "ScanValRel"


    ....of QualValRel.

    >....
    > (Scan)*(Val)(Rel)(QualValRel)*
    >
    > but this allows
    >
    > ScanValValRel (as it finds ValRel as part of this string). I don't want
    > it to do that.


    And it won't do that (since that re will only match ValRel or
    ValRelQualValRel, etc., preceded by any number of Scan), so if it does
    you've mistyped the re.

    It might help if you actually said what you wanted to match, rather
    than just giving things which you say have failed.




    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue, Jul 19, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anand

    Regular Expression help...

    Anand, Jul 9, 2003, in forum: Perl
    Replies:
    1
    Views:
    1,225
    Eric J. Roode
    Jul 9, 2003
  2. Eric B.
    Replies:
    1
    Views:
    431
    Jim Gibson
    Dec 17, 2004
  3. VSK
    Replies:
    2
    Views:
    2,282
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    839
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,942
    vforvikash
    Dec 29, 2008
Loading...

Share This Page