Re: Regex question

2021-02-12 Thread Christopher Stone
On 02/12/2021, at 06:07, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> 
> I seem to be having a Brain Cloud¹ moment, but I am trying to match a pattern 
> like this:
> 
> foo+(anything)# or foo# and NOT match
> 
> foobar#
> foobar+(anything)#
> foob#
> foob+(anything)#
> etc
> 
> foo+# is invalid and cannot occur in my dataset.
> 
> Basically, the + is optional, but if it is there, I have to account for 
> anything after the + up to the # but not account for anything after foo 
> unless the + is there.


Something like this?

foo#|foo\+.+?#


-Chris

-- 
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 here. 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/DF9BB7A5-1A26-45A1-974F-05E1C6B81D5E%40gmail.com.


Re: Regex question

2021-02-12 Thread Neil Faiman
That looks like

foo(\+.*?)?#

(Using  .*? instead of .* ensures that if you have a line like "foo+bar#  
foo+mung#", it will match two occurrences, "foo+bar#" and "foo+mung#", rather 
than a single occurrence with foo followed by the string "bar# foo+mung" 
followed by #.

Regards,

Neil Faiman

> On Feb 12, 2021, at 7:07 AM, @lbutlr  wrote:
> 
> I seem to be having a Brain Cloud¹ moment, but I am trying to match a pattern 
> like this:
> 
> foo+(anything)# or foo# and NOT match
> 
> foobar#
> foobar+(anything)#
> foob#
> foob+(anything)#
> etc
> 
> foo+# is invalid and cannot occur in my dataset.
> 
> Basically, the + is optional, but if it is there, I have to account for 
> anything after the + up to the # but not account for anything after foo 
> unless the + is there.
> 
> I started with foo\+?.*# but that obviously failed and now I'm looking at it 
> and it's 0500 and I should've been in bed 7 hours ago.
> 
> And yes, I am going to feel real stupid.
> 
> 1. 
> 
> -- 
> I want to secede, but I don't know what state I'm in. - Bart Simpson, 2012
> 
> -- 
> 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 here. 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/82052BB3-5773-4E7C-9E6D-6894047AE2F8%40kreme.com.

-- 
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 here. 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/95E94605-6109-411B-B9F7-8FB01125202B%40faiman.org.


Regex question

2021-02-12 Thread @lbutlr
I seem to be having a Brain Cloud¹ moment, but I am trying to match a pattern 
like this:

foo+(anything)# or foo# and NOT match

foobar#
foobar+(anything)#
foob#
foob+(anything)#
etc

foo+# is invalid and cannot occur in my dataset.

Basically, the + is optional, but if it is there, I have to account for 
anything after the + up to the # but not account for anything after foo unless 
the + is there.

I started with foo\+?.*# but that obviously failed and now I'm looking at it 
and it's 0500 and I should've been in bed 7 hours ago.

And yes, I am going to feel real stupid.

1. 

-- 
I want to secede, but I don't know what state I'm in. - Bart Simpson, 2012

-- 
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 here. 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/82052BB3-5773-4E7C-9E6D-6894047AE2F8%40kreme.com.


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.


Tricky regex question

2019-02-02 Thread jgill
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: Regex Question

2015-08-24 Thread Oliver Taylor
Holger,

When I need to figure out a regex pattern I have a rough idea of, but want to 
refine, tools like the one linked below are vital. 

https://regex101.com/



 On Aug 23, 2015, at 8:10 PM, 'Holger B' via BBEdit Talk 
 bbedit@googlegroups.com wrote:
 
 Hi Alex,
 
 this is actually quite a good approach. It doesn't solve it in one pass, but 
 thinking to start at the end of the line (\r) seems to be a good idea which I 
 somehow didn't think of before.
 
 I tried this: \n\s+-\s?(.+)$
 
 and replace with: \1,
 
 which results in categories:A, B, C,
 
 Seems to be as close as I can get in one pass and in the end much simpler 
 than my initial approach ;)
 
 Thanks,
 Holger
 
 On 23/08/2015 at 15:05:42 HKT gr...@goldweb.com.au wrote:
 
 Would it be sufficient to replace s/\n\s+-/,/ — This would make
 
 categories:
 - A
 - B
 - C
 
 Turn into:
 
 categories:, A, B, C
 
 Then a second pass to remove the first comma s/:,/:/
 
 categories: A, B, C
 
 Alex
 
 On 23 Aug 2015, at 03:56, 'Holger B' via BBEdit Talk 
 bbedit@googlegroups.com
 wrote:
 
 Hi,
 
 I know there's some very talented regex people on this list, so after
 unsuccessfully trying to solve this, I'm giving it a shot here.
 
 I'm trying to achieve the following search/replace and am not sure if it's
 even possible in one pass. I believe the solution would be to find an 
 unknown number of a repeating pattern and capturing each one at the same 
 time.
 
 The text I'm searching looks like this, with the categories ranging from one
 to n:
 
 categories:
 - cat 1
 - cat 2
 - …
 - cat n
 
 The result I would like to achieve should be:
 
 categories: cat 1, cat 2, …, cat n
 
 The way I solved it for now is by modifying the pattern for different 
 numbers
 of categories, but obviously this is not very efficient…
 
 Search, e.g. 5 categories:
 categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\
 s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)
 
 Replace:
 
 categories: \1, \4, \6, \8, \10, \12\r
 
 Would appreciate any help or pointers on this.
 
 Thanks and a good weekend,
 Holger
 
 --
 This is the BBEdit Talk public discussion group. If you have a feature 
 request
 or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit
 
 --- 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.
 
 -- 
 This is the BBEdit Talk public discussion group. If you have a feature 
 request or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit
 
 --- 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.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-24 Thread 'Holger B' via BBEdit Talk
Thanks Oliver, this is a great tool, like it a lot. Less 
comprehensive but also nice is http://www.regexr.com/.


Cheers,
Holger

On 24/08/2015 at 15:32:18 HKT m...@olivertaylor.net wrote:


Holger,

When I need to figure out a regex pattern I have a rough idea 
of, but want to refine, tools like the one linked below are vital.

https://regex101.com/




On Aug 23, 2015, at 8:10 PM, 'Holger B' via BBEdit Talk

bbedit@googlegroups.com wrote:


Hi Alex,

this is actually quite a good approach. It doesn't solve it in one pass, but
thinking to start at the end of the line (\r) seems to be a 
good idea which I somehow didn't think of before.


I tried this: \n\s+-\s?(.+)$

and replace with: \1,

which results in categories:A, B, C,

Seems to be as close as I can get in one pass and in the end much simpler than

my initial approach ;)


Thanks,
Holger


On 23/08/2015 at 15:05:42 HKT gr...@goldweb.com.au wrote:
  Would it be sufficient to replace s/\n\s+-/,/ — This 
would make

  categories:
- A
- B
- C
  Turn into:
  categories:, A, B, C
  Then a second pass to remove the first comma s/:,/:/
  categories: A, B, C
  Alex


On 23 Aug 2015, at 03:56, 'Holger B' via BBEdit Talk

bbedit@googlegroups.com

wrote:
  Hi,
  I know there's some very talented regex people on this 
list, so after

unsuccessfully trying to solve this, I'm giving it a shot here.
  I'm trying to achieve the following search/replace and am 
not sure if it's

even possible in one pass. I believe the solution would be to find an unknown

number of a repeating pattern and capturing each one at the same time.
  The text I'm searching looks like this, with the 
categories ranging from one

to n:

  categories:
- cat 1
- cat 2
- …
- cat n
  The result I would like to achieve should be:
  categories: cat 1, cat 2, …, cat n
  The way I solved it for now is by modifying the pattern 
for different

numbers

of categories, but obviously this is not very efficient…

  Search, e.g. 5 categories:



categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\

s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)

  Replace:
  categories: \1, \4, \6, \8, \10, \12\r
  Would appreciate any help or pointers on this.
  Thanks and a good weekend,
Holger
  --
This is the BBEdit Talk public discussion group. If you have a feature

request

or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit
  --- 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.


--
This is the BBEdit Talk public discussion group. If you have a feature request

or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 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.




--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-24 Thread 'Holger B' via BBEdit Talk

On 24/08/2015 at 17:39:08 HKT listmeis...@suddenlink.net wrote:


Essentially you're wanting to find a variable string, massage that string a
fair amount into its final form, and replace it.

The less regular the string is the more difficult it is to manage with a
single-pass regex find/replace.

It becomes much easier to find the string, do all necessary adjustments,
replace it, and repeat.


Hi Chris,

yes, this sounds like what I was trying to do. I will give the 
Script a shot and see what it does.


Basically I was curious if it was possible in one pass and if 
there's something I don't know about that would solve this, but 
it looks like this will always be easier in multiple passes as 
you have pointed out. And in that case, text factories FTW ;)


Thanks everyone for the suggestions  help and have a good day,
Holger

--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-24 Thread Christopher Stone
On Aug 24, 2015, at 05:28, 'Holger B' via BBEdit Talk bbedit@googlegroups.com 
wrote:
 And in that case, text factories FTW ;)
__

Hey Holger,

Scripts tend to be faster than text factories.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-24 Thread Christopher Stone
On Aug 23, 2015, at 22:00, 'Holger B' via BBEdit Talk bbedit@googlegroups.com 
wrote:
 See a portion of the file below. The amount of categories as well as tags are 
 the ones that can vary and getting it in one pass could replace both of them. 
 I suppose it's not possible in one pass though, but am curious if I'm missing 
 something.
__

Hey Holger,

Essentially you're wanting to find a variable string, massage that string a 
fair amount into its final form, and replace it.

The less regular the string is the more difficult it is to manage with a 
single-pass regex find/replace.

It becomes much easier to find the string, do all necessary adjustments, 
replace it, and repeat.

Try this AppleScript and see if it does what you're wanting to accomplish.

---
tell application BBEdit
  set bbeditApp to a reference to it
  set foundRec to {found:true}
  
  tell front text window's text
select insertion point before it

repeat while found of foundRec is true
  
  set foundRec to find ^categories:(\\s+^[[:blank:]]+- \\b[\\w ]+\\b)+ 
options ¬
{search mode:grep, case sensitive:false} with selecting match
  
  if found of foundRec is true then
tell bbeditApp
  set newText to replace \\s+-[[:blank:]]+(\\b[\\w ]+\\b) using \\1, 
 searchingString (get contents of text of found object of foundRec) options 
{search mode:grep, case sensitive:false}
  set newText to replace (categories:)(.+?), $ using \\1 \\2 
searchingString newText options {search mode:grep, case sensitive:false}
end tell
set (contents of found object of foundRec) to newText
  end if
  
end repeat

  end tell
end tell
---

If I was doing this job frequently on fairly hefty files I'd probably write a 
Perl text filter to speed things up.

--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-23 Thread Alex Satrapa
Would it be sufficient to replace s/\n\s+-/,/ — This would make

categories:
 - A
 - B
 - C

Turn into:

categories:, A, B, C

Then a second pass to remove the first comma s/:,/:/

categories: A, B, C

Alex

 On 23 Aug 2015, at 03:56, 'Holger B' via BBEdit Talk 
 bbedit@googlegroups.com wrote:
 
 Hi,
 
 I know there's some very talented regex people on this list, so after 
 unsuccessfully trying to solve this, I'm giving it a shot here.
 
 I'm trying to achieve the following search/replace and am not sure if it's 
 even possible in one pass. I believe the solution would be to find an unknown 
 number of a repeating pattern and capturing each one at the same time.
 
 The text I'm searching looks like this, with the categories ranging from one 
 to n:
 
 categories:
  - cat 1
  - cat 2
  - …
  - cat n
 
 The result I would like to achieve should be:
 
 categories: cat 1, cat 2, …, cat n
 
 The way I solved it for now is by modifying the pattern for different numbers 
 of categories, but obviously this is not very efficient…
 
 Search, e.g. 5 categories:
 
 categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)
 
 Replace:
 
 categories: \1, \4, \6, \8, \10, \12\r
 
 Would appreciate any help or pointers on this.
 
 Thanks and a good weekend,
 Holger
 
 --
 This is the BBEdit Talk public discussion group. If you have a feature 
 request or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit
 
 --- 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.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Regex Question

2015-08-23 Thread 'Holger B' via BBEdit Talk

Hi Alex,

this is actually quite a good approach. It doesn't solve it in 
one pass, but thinking to start at the end of the line (\r) 
seems to be a good idea which I somehow didn't think of before.


I tried this: \n\s+-\s?(.+)$

and replace with: \1,

which results in categories:A, B, C,

Seems to be as close as I can get in one pass and in the end 
much simpler than my initial approach ;)


Thanks,
Holger

On 23/08/2015 at 15:05:42 HKT gr...@goldweb.com.au wrote:


Would it be sufficient to replace s/\n\s+-/,/ — This would make

categories:
- A
- B
- C

Turn into:

categories:, A, B, C

Then a second pass to remove the first comma s/:,/:/

categories: A, B, C

Alex


On 23 Aug 2015, at 03:56, 'Holger B' via BBEdit Talk bbedit@googlegroups.com

wrote:


Hi,

I know there's some very talented regex people on this list, so after

unsuccessfully trying to solve this, I'm giving it a shot here.


I'm trying to achieve the following search/replace and am not sure if it's
even possible in one pass. I believe the solution would be to 
find an unknown number of a repeating pattern and capturing 
each one at the same time.


The text I'm searching looks like this, with the categories ranging from one

to n:


categories:
- cat 1
- cat 2
- …
- cat n

The result I would like to achieve should be:

categories: cat 1, cat 2, …, cat n

The way I solved it for now is by modifying the pattern for different numbers

of categories, but obviously this is not very efficient…


Search, e.g. 5 categories:



categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\
s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)


Replace:

categories: \1, \4, \6, \8, \10, \12\r

Would appreciate any help or pointers on this.

Thanks and a good weekend,
Holger

--
This is the BBEdit Talk public discussion group. If you have a feature request

or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 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.




--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-23 Thread 'Holger B' via BBEdit Talk

Hi Patrick,

see a portion of the file below. The amount of categories as 
well as tags are the ones that can vary and getting it in one 
pass could replace both of them. I suppose it's not possible in 
one pass though, but am curious if I'm missing something.


---
title: Newsletter Design Issues with Outlook 2010
author: Holger Bartel
layout: post
permalink: /2012/04/newsletter-design-issues-with-outlook-2010/
categories:
  - Code
  - Design
  - Web Dev
tags:
  - css
  - newsletter
  - outlook 2010
  - web development
---

Best,
Holger




On 23/08/2015 at 03:18:24 HKT pwool...@barebones.com wrote:

Can you please supply a small section of the actual data (if 
possible), since though notionally I expect this shouldn't take 
more than two passes, that may not hold up. :)


Regards,

Patrick Woolsey
==
Bare Bones Software, Inc. http://www.barebones.com/



On 8/23/15 at 1:56 PM, bbedit@googlegroups.com ('Holger B' via 
BBEdit Talk) wrote:



Hi,

I know there's some very talented regex people on this list, 
so after unsuccessfully trying to solve this, I'm giving it a 
shot here.


I'm trying to achieve the following search/replace and am not 
sure if it's even possible in one pass. I believe the solution 
would be to find an unknown number of a repeating pattern and 
capturing each one at the same time.


The text I'm searching looks like this, with the categories 
ranging from one to n:


categories:
- cat 1
- cat 2
- …
- cat n

The result I would like to achieve should be:

categories: cat 1, cat 2, …, cat n

The way I solved it for now is by modifying the pattern for 
different numbers of categories, but obviously this is not 
very efficient…


Search, e.g. 5 categories:

categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)

\

s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)

Replace:

categories: \1, \4, \6, \8, \10, \12\r

Would appreciate any help or pointers on this.

Thanks and a good weekend,
Holger





--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-22 Thread Patrick Woolsey
Can you please supply a small section of the actual data (if 
possible), since though notionally I expect this shouldn't take 
more than two passes, that may not hold up. :)


Regards,

 Patrick Woolsey
==
Bare Bones Software, Inc. http://www.barebones.com/



On 8/23/15 at 1:56 PM, bbedit@googlegroups.com ('Holger B' via 
BBEdit Talk) wrote:



Hi,

I know there's some very talented regex people on this list, so 
after unsuccessfully trying to solve this, I'm giving it a shot here.


I'm trying to achieve the following search/replace and am not 
sure if it's even possible in one pass. I believe the solution 
would be to find an unknown number of a repeating pattern and 
capturing each one at the same time.


The text I'm searching looks like this, with the categories 
ranging from one to n:


categories:
- cat 1
- cat 2
- …
- cat n

The result I would like to achieve should be:

categories: cat 1, cat 2, …, cat n

The way I solved it for now is by modifying the pattern for 
different numbers of categories, but obviously this is not very efficient…


Search, e.g. 5 categories:

categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\
s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)

Replace:

categories: \1, \4, \6, \8, \10, \12\r

Would appreciate any help or pointers on this.

Thanks and a good weekend,
Holger



--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Regex Question

2015-08-22 Thread 'Holger B' via BBEdit Talk

Hi,

I know there's some very talented regex people on this list, so 
after unsuccessfully trying to solve this, I'm giving it a shot here.


I'm trying to achieve the following search/replace and am not 
sure if it's even possible in one pass. I believe the solution 
would be to find an unknown number of a repeating pattern and 
capturing each one at the same time.


The text I'm searching looks like this, with the categories 
ranging from one to n:


categories:
  - cat 1
  - cat 2
  - …
  - cat n

The result I would like to achieve should be:

categories: cat 1, cat 2, …, cat n

The way I solved it for now is by modifying the pattern for 
different numbers of categories, but obviously this is not very efficient…


Search, e.g. 5 categories:

categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)

Replace:

categories: \1, \4, \6, \8, \10, \12\r

Would appreciate any help or pointers on this.

Thanks and a good weekend,
Holger

--
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email

supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.


Re: Regex Question

2015-08-22 Thread Kerri Hicks
I'm not sure I understand your use case fully, but if I do, you can just
grep search

^- (.*?)\r

and replace with

\1,

Hope this helps,
--Kerri

On Sat, Aug 22, 2015 at 1:56 PM, 'Holger B' via BBEdit Talk 
bbedit@googlegroups.com wrote:

 Hi,

 I know there's some very talented regex people on this list, so after
 unsuccessfully trying to solve this, I'm giving it a shot here.

 I'm trying to achieve the following search/replace and am not sure if it's
 even possible in one pass. I believe the solution would be to find an
 unknown number of a repeating pattern and capturing each one at the same
 time.

 The text I'm searching looks like this, with the categories ranging from
 one to n:

 categories:
   - cat 1
   - cat 2
   - …
   - cat n

 The result I would like to achieve should be:

 categories: cat 1, cat 2, …, cat n

 The way I solved it for now is by modifying the pattern for different
 numbers of categories, but obviously this is not very efficient…

 Search, e.g. 5 categories:


 categories:\r\s+-\s?((.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)(\r\s+-\s?(.+)\s?)

 Replace:

 categories: \1, \4, \6, \8, \10, \12\r

 Would appreciate any help or pointers on this.

 Thanks and a good weekend,
 Holger

 --
 This is the BBEdit Talk public discussion group. If you have a feature
 request or would like to report a problem, please email
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit

 --- 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.


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit

--- 
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.