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.

Reply via email to