Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Re: Differential pattern match

Reply
Thread Tools

Re: Differential pattern match

 
 
Graham S
Guest
Posts: n/a
 
      10-06-2012

"Ben Morrow" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Quoth "Graham" <(E-Mail Removed)>:
>>
>> > / ((?: (?: \b [12][0-9] \b | [0-9Xx] ) [ ]{0,2} ){6}) /x did the
>> > business and produces exactly the output I want !! (basically your code
>> > with an additional pair of parentheses on the extreme left and right to
>> > capture the output
>> >
>> > Tested it on a number of tabs with 100% success !!
>> >
>> > Apart from the following line - which I obviously wouldn't expect to
>> > match
>> > 8X998X 7X778X 6X776X 5X556X AXBBAX 9X99AX
>> > 8X998X 7X778X 6X776X 5X556X AXBBAX
>> > 9X99AXDon't
>> > know what's going on there with the As and the B's - maybe it a typo,
>> > or
>> > maybe it means something I'm not aware of (I'm no guitarist either!)

>
> I presume you can see how to fix that, if you want to? (Just treat A and
> B the same as X.)
>
>> Hmm - I spoke a little to soon! It's fine with a few of the 'commercial'
>> tabs I've fed it, but when I try and break it, unfortunately I can with
>> the
>> likes of....
>>
>> It doesn't like this 'xx10 10 10x' very muchor this 'x10 10 10 9x'
>> eitherwhich match as It doesn't like this 'xx10 10 10x' very muchor this
>> 'x10 10 10 9x' eitherGraham

>
> Well, no. I didn't know those were allowed, either: they have a
> single-character fret 'number' (which happens to be an X) right next to
> a double-digit number, with no space. The only simple way I can see to
> fix that is to replace the first \b with
>
> (?: (?<= [Xx]) | \b )
>
> and the second with
>
> (?: (?= [Xx]) | \b )
>
> Those constructions are called 'lookahead/behind', and like \b, ^ and $
> they are zero-width assertions that match between characters. (?<=foo)
> matches at a point in the string immediately preceded by 'foo', (?=foo)
> at a point immediately followed. So the new pattern will allow Xs to
> butt up against two-digit fret numbers, but not other digits or letters.
>
> This is turning into quite a complicated pattern. Make sure you write it
> with plenty of whitespace (and newlines and indentation, where that's
> helpful), and if necessary include comments within the pattern to
> explain what the various bits do.
>
> Ben
>

Superb!! Works a treat!!
I'm pretty convinced this will match 99.9% of guitar tabs out there - most
of them are straightforward 6 character strings of X's and numerals played
below the 10th fret anyway, but this pattern match should catch the vast
majority of the more complex ones.
And many thanks for explaining some of the finer points of pattern matching

Graham


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Differential pattern match Graham S Perl Misc 7 10-12-2012 11:11 AM
Re: Differential pattern match Justin C Perl Misc 0 10-04-2012 03:58 PM
SCSI Long Cables, High Voltage Differential Signals and Data Skew? Will Hay A+ Certification 1 03-04-2004 06:44 PM
solving differential equation greg.smith C Programming 3 09-24-2003 09:37 AM



Advertisments