Re: Tricky regex question

2019-02-02 Thread jgill
This one seem to work for me (In BBEdit anyway). With this framework, I can 
add the more exotic chords if necessary.

Thanks (to everyone).

On Saturday, February 2, 2019 at 6:40:56 PM UTC, ThePorgie wrote:
>
> Fiddle with for a bit...Notice in the thread MPasini had a pattern that 
> worked on your example. However I modified your example to include 
> possibilities that could arise...And I'm not sure if I have got all of 
> these.
>
> Here is the example I came up with:
> 
>   B7   E  A  Am  E  
> This is a line of a song
>E
> This is a line of a song
>   B7  E  E7
> This is line 7 of a song
>  A
> This is a line of a song
>   E
> This is the 9th line of a song
>  B7dim
> This is a line of a song aug
>   EA Am  E  
> This is a line of a song dim
>
> C D E F G A B C#m
>
> A small flower
>
> C D E F G A B♭ C
>
> Am I going
> __
>
> Depending on the result you desire either replace or extract with:
> ^([A-G\s])(?(1)([A-Gm679#♭iu\s]+)$)
>
>
> On Saturday, February 2, 2019 at 11:59:49 AM UTC-5, jgill wrote:
>>
>> I've been banging my head all afternoon trying to derive a regex the will 
>> identify lines (of a song) that contains chords.
>>
>> eg
>>
>> E   B7   E  A  Am  E  
>> This is a line of a song
>>E
>> This is a line of a song
>>   B7  E  E7
>> This is a line of a song
>>  A
>> This is a line of a song
>>   E
>> This is a line of a song
>>  B7
>> This is a line of a song
>>   EA Am  E  
>> This is a line of a song
>>
>> There could be spaces before or after the chord names and the only way I 
>> can think to distinguish chords from regular words is that chords are 
>> likely to have more than one space after them - or a newline
>>
>> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
>>
>> but the spaces and newlines have me flumoxed.
>>
>> Can anyone help?
>>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread Marek Stepanek
^\s*([A-Z\dm♭#bdimsu]+\s+)+

Good night folx 


ps: how to put “dim” or “sus" into a character class as a string?


> On 2. Feb 2019, at 19:56, bruce linde  wrote:
> 
> yes, but… what about Eb7#9 or C#7#9 or A9sus?

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread bruce linde
yes, but… what about Eb7#9 or C#7#9 or A9sus?

you’re assuming missionary position chords and not (for example) steely dan or 
jazz.

i am still not sure what the goal is… put the chords in bold, but not the 
lyrics? create a ‘chords only’ version for the non-singers in the band?

you said you want to style them differently…

why not search for any line that is NOT just words and single spaces, and wrap 
it in (for example) bold tags, or a span/css tag?






 

 







> On Feb 2, 2019, at 9:53 AM, Marek Stepanek  
> wrote:
> 
> 
> So try this:
> 
> ^\s*([A-Z\dm♭#dim]+\s+)+
> 
> it’s working on this example:
> 
> 
> E   B7   E  A  Am  E  
> This is a line of a song
>E
> This is a line of a song
>   B7  E  E7
> This is a line of a song
>  A
> This is a line of a song
>   E
> This is a line of a song
>  B7
> This is a line of a song
>   EA Am  E  
> This is a line of a song
>A#  EA Am  E  
> This is a line of a song
>A♭ Adim  EA Am  E  
> This is a line of a song
> 
> 
> 
> 
> 
>> On 2. Feb 2019, at 18:45, jgill  wrote:
>> 
>> I need to identify chord lines and non-chord lines so that I can style them 
>> differently on a web page. Remember, I'm not just looking for [A-G] but A7, 
>> Am, A#, A♭dim etc
>> 
>> On Saturday, February 2, 2019 at 5:36:42 PM UTC, Marek wrote:
>> Hello jgill!
>> 
>> 
>> You forgot to tell us, what you exactly want to achieve. Do you want to 
>> extract the lines with the chords? 
>> 
>> Try with regex: search with grep case sensitive: 
>> 
>> \s*([A-Z\dm]+\s+)+
>> 
>> 
>> Best greetings from Munich
>> 
>> 
>> marek
>> 
>> 
>> 
>>> On 2. Feb 2019, at 17:59, jgill  wrote:
>>> 
>>> I've been banging my head all afternoon trying to derive a regex the will 
>>> identify lines (of a song) that contains chords.
>>> 
>>> eg
>>> 
>>> E   B7   E  A  Am  E  
>>> This is a line of a song
>>>E
>>> This is a line of a song
>>>   B7  E  E7
>>> This is a line of a song
>>>  A
>>> This is a line of a song
>>>   E
>>> This is a line of a song
>>>  B7
>>> This is a line of a song
>>>   EA Am  E  
>>> This is a line of a song
>>> 
>>> There could be spaces before or after the chord names and the only way I 
>>> can think to distinguish chords from regular words is that chords are 
>>> likely to have more than one space after them - or a newline
>>> 
>>> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
>>> 
>>> but the spaces and newlines have me flumoxed.
>>> 
>>> Can anyone help?
>>> 
>>> -- 
>>> This is the BBEdit Talk public discussion group. If you have a 
>>> feature request or need technical support, please email
>>> "sup...@barebones.com" rather than posting to the group.
>>> Follow @bbedit on Twitter: 
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "BBEdit Talk" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to bbedit+un...@googlegroups.com.
>>> To post to this group, send email to bbe...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/bbedit.
>> 
>> 
>> -- 
>> This is the BBEdit Talk public discussion group. If you have a 
>> feature request or need technical support, please email
>> "supp...@barebones.com" rather than posting to the group.
>> Follow @bbedit on Twitter: 
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to bbedit+unsubscr...@googlegroups.com.
>> To post to this group, send email to bbedit@googlegroups.com.
>> Visit this group at https://groups.google.com/group/bbedit.
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.





bruce linde
5 happiness webmaster (four more than the competition!)
http://www.5happy.com/
http://www.5happy.com/blahg
510.530.1331 office (and best place to leave messages)
510.206.9730 mobile

(shift key available upon request)






-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 

Re: Tricky regex question

2019-02-02 Thread Marek Stepanek

So try this:

^\s*([A-Z\dm♭#dim]+\s+)+

it’s working on this example:


E   B7   E  A  Am  E  
This is a line of a song
   E
This is a line of a song
  B7  E  E7
This is a line of a song
 A
This is a line of a song
  E
This is a line of a song
 B7
This is a line of a song
  EA Am  E  
This is a line of a song
   A#  EA Am  E  
This is a line of a song
   A♭ Adim  EA Am  E  
This is a line of a song





> On 2. Feb 2019, at 18:45, jgill  wrote:
> 
> I need to identify chord lines and non-chord lines so that I can style them 
> differently on a web page. Remember, I'm not just looking for [A-G] but A7, 
> Am, A#, A♭dim etc
> 
> On Saturday, February 2, 2019 at 5:36:42 PM UTC, Marek wrote:
> Hello jgill!
> 
> 
> You forgot to tell us, what you exactly want to achieve. Do you want to 
> extract the lines with the chords? 
> 
> Try with regex: search with grep case sensitive: 
> 
> \s*([A-Z\dm]+\s+)+
> 
> 
> Best greetings from Munich
> 
> 
> marek
> 
> 
> 
>> On 2. Feb 2019, at 17:59, jgill gmail.com 
>> > wrote:
>> 
>> I've been banging my head all afternoon trying to derive a regex the will 
>> identify lines (of a song) that contains chords.
>> 
>> eg
>> 
>> E   B7   E  A  Am  E  
>> This is a line of a song
>>E
>> This is a line of a song
>>   B7  E  E7
>> This is a line of a song
>>  A
>> This is a line of a song
>>   E
>> This is a line of a song
>>  B7
>> This is a line of a song
>>   EA Am  E  
>> This is a line of a song
>> 
>> There could be spaces before or after the chord names and the only way I can 
>> think to distinguish chords from regular words is that chords are likely to 
>> have more than one space after them - or a newline
>> 
>> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
>> 
>> but the spaces and newlines have me flumoxed.
>> 
>> Can anyone help?
>> 
>> -- 
>> This is the BBEdit Talk public discussion group. If you have a 
>> feature request or need technical support, please email
>> "sup...@ <>barebones.com " rather than posting to the 
>> group.
>> Follow @bbedit on Twitter: > >
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to bbedit+un...@ <>googlegroups.com .
>> To post to this group, send email to bbe...@ <>googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/bbedit 
>> .
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter:  >
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to bbedit@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/bbedit 
> .

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread bruce linde
actually, you don’t. you need to identify one or the other…. if you match one, 
it ain’t the other and you can format accordingly.







> On Feb 2, 2019, at 9:45 AM, jgill  > wrote:
> 
> I need to identify chord lines and non-chord lines so that I can style them 
> differently on a web page. Remember, I'm not just looking for [A-G] but A7, 
> Am, A#, A♭dim etc
> 
> On Saturday, February 2, 2019 at 5:36:42 PM UTC, Marek wrote:
> Hello jgill!
> 
> 
> You forgot to tell us, what you exactly want to achieve. Do you want to 
> extract the lines with the chords? 
> 
> Try with regex: search with grep case sensitive: 
> 
> \s*([A-Z\dm]+\s+)+
> 
> 
> Best greetings from Munich
> 
> 
> marek
> 
> 
> 
>> On 2. Feb 2019, at 17:59, jgill > wrote:
>> 
>> I've been banging my head all afternoon trying to derive a regex the will 
>> identify lines (of a song) that contains chords.
>> 
>> eg
>> 
>> E   B7   E  A  Am  E  
>> This is a line of a song
>>E
>> This is a line of a song
>>   B7  E  E7
>> This is a line of a song
>>  A
>> This is a line of a song
>>   E
>> This is a line of a song
>>  B7
>> This is a line of a song
>>   EA Am  E  
>> This is a line of a song
>> 
>> There could be spaces before or after the chord names and the only way I can 
>> think to distinguish chords from regular words is that chords are likely to 
>> have more than one space after them - or a newline
>> 
>> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
>> 
>> but the spaces and newlines have me flumoxed.
>> 
>> Can anyone help?
>> 
>> -- 
>> This is the BBEdit Talk public discussion group. If you have a 
>> feature request or need technical support, please email
>> "sup...@barebones.com " rather than posting to the group.
>> Follow @bbedit on Twitter: > >
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "BBEdit Talk" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to bbedit+un...@googlegroups.com .
>> To post to this group, send email to bbe...@googlegroups.com .
>> Visit this group at https://groups.google.com/group/bbedit 
>> .
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "supp...@barebones.com " rather than posting to 
> the group.
> Follow @bbedit on Twitter:  >
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to bbedit@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/bbedit 
> .





bruce linde
5 happiness webmaster (four more than the competition!)
http://www.5happy.com/ 
http://www.5happy.com/blahg
510.530.1331 office (and best place to leave messages)
510.206.9730 mobile

(shift key available upon request)






-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread Mike Pasini


On Saturday, February 2, 2019 at 9:45:40 AM UTC-8, jgill wrote:
>
> I need to identify chord lines and non-chord lines so that I can style 
> them differently on a web page. Remember, I'm not just looking for [A-G] 
> but A7, Am, A#, A♭dim etc
>
>
Yep, it's tricky. This (https://regex101.com/r/xQ5vd6/4) works on your 
example text (surrounding chords with bold HTML tags) but will fail on any 
lyric line that begins with anything from A to G. And it doesn't handle the 
more complex chord designations (like flats).

Which would suggest the best approach would be a little Perl script you 
could access as a Text Filter in BBEdit that would just look at 
odd-numbered lines (assuming the chords are first in the selection) and add 
the HTML formatting where a chord is found, no doubt using several regexes, 
looking for the longer, more complex strings first.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread jgill
I need to identify chord lines and non-chord lines so that I can style them 
differently on a web page. Remember, I'm not just looking for [A-G] but A7, 
Am, A#, A♭dim etc

On Saturday, February 2, 2019 at 5:36:42 PM UTC, Marek wrote:
>
> Hello jgill!
>
>
> You forgot to tell us, what you exactly want to achieve. Do you want to 
> extract the lines with the chords? 
>
> Try with regex: search with grep case sensitive: 
>
> \s*([A-Z\dm]+\s+)+
>
>
> Best greetings from Munich
>
>
> marek
>
>
>
> On 2. Feb 2019, at 17:59, jgill > 
> wrote:
>
> I've been banging my head all afternoon trying to derive a regex the will 
> identify lines (of a song) that contains chords.
>
> eg
>
> E   B7   E  A  Am  E  
> This is a line of a song
>E
> This is a line of a song
>   B7  E  E7
> This is a line of a song
>  A
> This is a line of a song
>   E
> This is a line of a song
>  B7
> This is a line of a song
>   EA Am  E  
> This is a line of a song
>
> There could be spaces before or after the chord names and the only way I 
> can think to distinguish chords from regular words is that chords are 
> likely to have more than one space after them - or a newline
>
> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
>
> but the spaces and newlines have me flumoxed.
>
> Can anyone help?
>
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "sup...@barebones.com " rather than posting to the group.
> Follow @bbedit on Twitter: 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+un...@googlegroups.com .
> To post to this group, send email to bbe...@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/bbedit.
>
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Tricky regex question

2019-02-02 Thread David Rostenne
Hmm. What about removing the lines of the song instead? I’m sure an 
Applescript, awk or some other script can remove every second line, or just 
copy it to a new file, and then you won’t need to mess with regex’s.

https://stackoverflow.com/questions/2560411/how-to-remove-every-other-line-with-sed

https://unix.stackexchange.com/questions/219859/how-to-delete-every-second-line-from-a-file

Cheers,

Dave

> On 2-February-2019, at 11:59 AM, jgill  wrote:
> 
> I've been banging my head all afternoon trying to derive a regex the will 
> identify lines (of a song) that contains chords.
> 
> eg
> 
> E   B7   E  A  Am  E  
> This is a line of a song
>E
> This is a line of a song
>   B7  E  E7
> This is a line of a song
>  A
> This is a line of a song
>   E
> This is a line of a song
>  B7
> This is a line of a song
>   EA Am  E  
> This is a line of a song
> 
> There could be spaces before or after the chord names and the only way I can 
> think to distinguish chords from regular words is that chords are likely to 
> have more than one space after them - or a newline
> 
> I've got as far as [A-G][6|7|9|m|#|♯|b|♭|aug|dim]
> 
> but the spaces and newlines have me flumoxed.
> 
> Can anyone help?
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or need technical support, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter: 
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com.
> To post to this group, send email to bbedit@googlegroups.com.
> Visit this group at https://groups.google.com/group/bbedit.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or need technical support, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.