need help with regular expressions

Discussion in 'Perl Misc' started by tsahiasher@gmail.com, Dec 24, 2007.

  1. Guest

    hi,
    i need the correct regular expression to set the unnamed variable $1
    to any of "FantasyMFG", "Fantasy.NET", or "FantasyACC" in the
    following path:

    FantasyMFG/tags/2.1.16

    (where "FantasyMFG" may be replaced with any of the others)

    this is for a system we are using. i've been battling this for a while
    now, but there's a limit to how much time i can dedicate for this.

    thanks,
    tsahi
     
    , Dec 24, 2007
    #1
    1. Advertising

  2. Dr.Ruud Guest

    schreef:

    > i need the correct regular expression to set the unnamed variable $1
    > to any of "FantasyMFG", "Fantasy.NET", or "FantasyACC" in the
    > following path:
    >
    > FantasyMFG/tags/2.1.16
    >
    > (where "FantasyMFG" may be replaced with any of the others)
    >
    > this is for a system we are using. i've been battling this for a while
    > now, but there's a limit to how much time i can dedicate for this.


    So what have you tried sofar?
    (show minimal but complete code, that we can run)

    Maybe this helps:

    /(Fantasy(?:MFG|\.NET|ACC))/

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Dec 24, 2007
    #2
    1. Advertising

  3. <> wrote:

    > i need the correct regular expression to set the unnamed variable $1



    $1 has a name. It's name is "dollar one".


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
     
    Tad J McClellan, Dec 24, 2007
    #3
  4. wrote:
    >i need the correct regular expression to set the unnamed variable $1
    >to any of "FantasyMFG", "Fantasy.NET", or "FantasyACC" in the
    >following path:
    >
    >FantasyMFG/tags/2.1.16
    >
    >(where "FantasyMFG" may be replaced with any of the others)


    Well, does it really have to be a RE and $1? It would be much easier and
    probably faster to use a simple
    (split '/', 'FantasyMFG/tags/2.1.16')[0];
    instead.

    jue
     
    Jürgen Exner, Dec 24, 2007
    #4
  5. Guest

    On Dec 24, 11:18 am, "Dr.Ruud" <> wrote:
    > schreef:
    >
    > > i need the correct regular expression to set the unnamed variable $1
    > > to any of "FantasyMFG", "Fantasy.NET", or "FantasyACC" in the
    > > following path:

    >
    > > FantasyMFG/tags/2.1.16

    >
    > > (where "FantasyMFG" may be replaced with any of the others)

    >
    > > this is for a system we are using. i've been battling this for a while
    > > now, but there's a limit to how much time i can dedicate for this.

    >
    > So what have you tried sofar?
    > (show minimal but complete code, that we can run)
    >


    this isn't for my code. it's for a config file of a Perl program i'm
    using (Scmbug, if you are familiar with it). so far i tried

    Fantasy[\s\.\w]+ (seems to work, but the Scmbug developer said "it
    won't set the $1 unamed variable")

    (Fantasy.+?)/ and (.+?)/ (for some reason Scmbug took these literaly
    and not as REs)

    > Maybe this helps:
    >
    > /(Fantasy(?:MFG|\.NET|ACC))/
    >


    i'll try that and see if it works.

    Tsahi
     
    , Dec 25, 2007
    #5
    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. Chris R. Timmons

    Re: Help with regular expressions.

    Chris R. Timmons, Jul 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    411
    Chris R. Timmons
    Jul 4, 2003
  2. David Waz...

    Re: Help with regular expressions.

    David Waz..., Jul 4, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    403
    David Waz...
    Jul 4, 2003
  3. Jay Douglas
    Replies:
    0
    Views:
    644
    Jay Douglas
    Aug 15, 2003
  4. mike
    Replies:
    2
    Views:
    145
    Anthony Jones
    Oct 3, 2006
  5. Noman Shapiro
    Replies:
    0
    Views:
    262
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page