I think I can write the GREP code that matches the first four lines, but I am not sure how to do that for the *Comment* lines. Also, once I do that, how do I "write a regular expression that recognizes the sort keys within the line"?
I've also never used text factory. (Is it easier to use in BBEdit 15 than in BBEdit 14?) Howard On Monday 4 November 2024 at 11:53:49 am UTC-5 Neil Faiman wrote: > As far as I know, BBEdit simply supports sorting *lines* — not arbitrary > records represented by batches of text lines. But do not despair. All is > not lost. BBEdit has really robust support for sorting lines. > > I would start with a GREP that could match across multiple lines and > collapse them into a single line, with some arbitrary separator character > representing where the original line breaks were. (You might need two > patterns, one to collapse the multi-line Comments into a single line, and > then a second one to collapse all the line in the record into a single line. > > Now that each record is represented by a single line, you can write a > regular expression that recognizes the sort keys within the line. Then you > can use the “Sort using pattern“ feature of the Text > Sort Lines… command > to sort the records on those keys. > > Finally, you can reverse the process from the first step and split the > records back into multiple lines. > > Once you’ve got each of the steps perfected, you can create a text factory > that will apply them to a file automatically, and you should be good to go. > > Good luck, > Neil Faiman > > On Nov 4, 2024, at 11:35 AM, Howard <[email protected]> wrote: > > I have multiple records in a text file in the format below (seven sample > records shown). I want to sort all of them by *Author* and then, within > *Author,* *Created At*. In a record, the first four lines are always just > one line; however, the fifth line (*Comment*) can be up to 30-40 lines, > possibly more). > > Is this something that BBEdit can do? If it is, how can I do it? > > > -- This is the BBEdit Talk public discussion group. If you have a feature request or believe that the application isn't working correctly, please email "[email protected]" rather than posting here. Follow @bbedit on Mastodon: <https://mastodon.social/@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 [email protected]. To view this discussion visit https://groups.google.com/d/msgid/bbedit/a5df9a70-87df-480d-adc5-6434e918f34en%40googlegroups.com.
