# Differential pattern match - Page 2

•  Subject
• Author
• Posted on

## Re: Differential pattern match

A belated thanks to all who helped with this, but particularly Ben. I
particularly appreciated Ben hinting at the way forward but not giving me
the answer on a plate. The final capturing pattern match I eventually came
up with was
/ ((?: (?: (?:(?<=[Xx])|\b) [12][0-9] (?:(?=[Xx])|\b) | [xX0-9] )
[ ] )) /x
which works a treat (see http://guitartabs2notes.cleverpages.co.uk ) I may
expand this to include letters a-e (and A-E) which sometimes represent
guitar frets 10to- 14 - any more than this and I'll be matching a whole host
of 6 letter words as well as guitar chords. Cheers again everybody.

## Re: Differential pattern match

So what's '11x 11x'? Can this be decided without examining the
complete input? Examples of that:

11x 11x3
11x 11x 33
11x 11x
11x 11x 11x

## Re: Differential pattern match

'11x 11x' can only be
1-lowE string
1-A string
x-D string
1-G string
1-Bstring
x-highE string

'11x 11x3', if it was anything, would be
1-lowE string
1-A string
x-D string
11-G string
x-B string
3-highE string
but unplayable due to the stretch between the 3rd and 11th frets (and
assuming the a capo was used to barre at the first fret)

'11x 11x 33' if it was anything would be
11-lowE string
x-A string
11-D string
x-G string
3-B string
3-highE string
but again unplayable due to the stretch between the 3rd and 11th frets

11x 11x 11x can only be

11-lowE string
x-A string
11-D string
x-G string
11-B string
x-highE string

My brain can figure that out pretty easily. What it can't do is figure out a
pattern match that accounts for all the variables.

Graham S

## Re: Differential pattern match

[...]

[...]

And I assume that 11x 11x33 would be the same as 11x 11x 33. If this
is true, the sequence 11x 11x3 can mean 1 1 x 11 x 3 or 11 x 11 x 3,
depending on what, if anything comes after the final 3: Either this
needs to be parsed back to front and not front to back or it needs to
do a real exhaustive search with backtracking, based on knowing the
meaning/ semantics of the input, not just the patterns occuring in it.
And I don't think this can be done with regular expressions (I could,
of course, be wrong).

## Re: Differential pattern match

[snip]

I'm not conviced this is unplayable. Tab allows for, AIUI, two hands
on the neck with hammering/tapping techniques. Though maybe the
notation is different for 'tricks' like that... it's been a long time
since I played seriously... or even mucking about.

Justin.

--
Justin C, by the sea.