Re: Differential pattern match

Discussion in 'Perl Misc' started by Justin C, Oct 4, 2012.

  1. Justin C

    Justin C Guest

    On 2012-10-04, Graham <> wrote:
    > I need a pattern match that will match all of the following (and other
    > variants too)
    >
    > x1234x X99 10 10x x 12 12 12 12 12
    >
    > The characters refer to chord fingering on a 6 string guitar. Up to the 9th
    > fret, the figering is usually tabulated as on the left above, but beyond
    > this one or two spaces are usually left between double figures encounted
    > from the 10th-24th frets.
    >
    > The best pattern match I have found so far is
    > /[xX0-9][xX0-9\s]{4,20}[xX0-9]/
    >
    > This provides for a match of x, X, or a number 0-9 on the extreme left and
    > right side, and for a match of x,X, a number 0-9, or a space, for between 4
    > and 20 'atoms' between the extreme left and right 'atoms' . However, this
    > also picks up the masses of spaces between each chord itself. What I need to
    > do somehow is to count the spaces as the regex engine parses and have it
    > fail the match if more than two consecutive spaces are encountered. I figure
    > that extended regex sequences are probably the way to do this, but I've not
    > encountered them before. Any help welcome.



    They may not help, but there are several modules on CPAN relating to
    tab/guitar tab (I found one for ukelele tab too!). You may find you
    what you're doing has already been done.

    Justin.

    --
    Justin C, by the sea.
     
    Justin C, Oct 4, 2012
    #1
    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. hiwa
    Replies:
    0
    Views:
    653
  2. Victor
    Replies:
    2
    Views:
    669
    Victor
    May 17, 2004
  3. greg.smith

    solving differential equation

    greg.smith, Sep 22, 2003, in forum: C Programming
    Replies:
    3
    Views:
    446
    Bigdakine
    Sep 24, 2003
  4. Graham S

    Re: Differential pattern match

    Graham S, Oct 4, 2012, in forum: Perl Misc
    Replies:
    7
    Views:
    395
    Rainer Weikusat
    Oct 12, 2012
  5. Graham S

    Re: Differential pattern match

    Graham S, Oct 6, 2012, in forum: Perl Misc
    Replies:
    0
    Views:
    288
    Graham S
    Oct 6, 2012
Loading...

Share This Page