Thanks for your kind help, Brian, could you change the grep to work with any number of words in the string? In my example, there are four, but in reality, there could be any number of words. The other conditions remain.
- Marco. On Thursday, October 17, 2024 at 1:39:43 PM UTC+2 Brian Forte wrote: > On Thu, 17 Oct 2024 03:14:21 -0700 (PDT), mrcmrc wrote: > > a Grep syntax to change a string of text > > like this: > > > > *House, Big Apple, Today, Movie* > > > > into this: > > > > *[[House]] | [[Big Apple]] | [[Today]] | [[Movie]]* > > The regex below assumes > > 1. There are four word/phrase strings on each line. > 2. Each such word/phrase string begins with a majuscule. > 2. The first three such strings on each line are end > delimited by a comma. > 3. The fourth string is not so-delimited. > > Given this > > Search for > ^\*([A-Z].*),\s([A-Z].*),\s([A-Z].*),\s([A-Z].*)\* > > Replace with > \*\[\[\1\]\] | \[\[\2\]\] | \[\[\3\]\] | \[\[\4\]\]\* > > When I use the above on this, slightly expanded and varied, example: > > *House, Big Apple, Today, Movie* > *Word, Yesterday, Peter Piper, Film* > *Content Question, Overmorrow, Helena, Still Photograph* > > It returns the following: > > *[[House]] | [[Big Apple]] | [[Today]] | [[Movie]]* > *[[Word]] | [[Yesterday]] | [[Peter Piper]] | [[Film]]* > *[[Content Question]] | [[Overmorrow]] | [[Helena]] | [[Still > Photograph]]* > > Hope this helps. > > Regards, > > Brian Forte. > -- > Brian Forte > <[email protected]> > -- 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 on the web visit https://groups.google.com/d/msgid/bbedit/ad8f1c5d-6fed-4e43-b53c-aca09dabb217n%40googlegroups.com.
