Quick question: For AppleScript you need to double escape, right? so:

   - in AppleScript: \\*
   - becomes \* in BBEdit
   - to find "*"


On Fri, 17 Mar 2023 at 13:36, Bruce Van Allen <[email protected]> wrote:

> Oops - I mis-typed one bit: the inner part of the find pattern should be
> “[^*]” - asterisk instead of plus sign.
>
> tell application “BBEdit"
>   tell front text window
>     replace "/\\*([^*]*?)\\*/" using "<!--\\1-->" options ¬
> {search mode:grep, case sensitive:false, starting at top:true}
>   end tell
> end tell
>
>
>     — Bruce
>
> _bruce__van_allen__santa_cruz_ca_
>
>
>
>
>
> > On Mar 17, 2023, at 6:08 AM, Bruce Van Allen <[email protected]> wrote:
> >
> > Here’s a slightly amended version of your script:
> >
> > tell application “BBEdit”
> >  tell front text window
> >    replace "/\\*([^+]*?)\\*/" using "<!--\\1-->" options ¬
> > {search mode:grep, case sensitive:false, starting at top:true}
> >  end tell
> > end tell
> >
> > The differences are:
> >
> > - no parentheses () surrounding the whole find pattern because that
> becomes the first capture, which you use in the replacement pattern as ‘\1’.
> >
> > - added parens around the inner part of the find pattern, in order to
> capture what’s between the JS comment markers.
> >
> > -  if you needed to keep that outer parens capture for some other
> reason, then change the replacement pattern to “<!—\\2—>” (assuming that
> part stays the second parens-capture).
> >
> > - I omitted the replace “%@“ line to keep this part of the script clear.
> >
> > Using the script as I wrote it above
> >
> > /* some commented stuff */ /*some more*/
> >
> > And /* some more*/
> >
> > is transformed in one step into
> >
> > <!-- some commented stuff --> <!--some more-->
> >
> > And <!-- some more-->
> >
> >
> > HTH
> >
> >    — Bruce
> >
> > _bruce__van_allen__santa_cruz_ca_
> >
> >
> >
> >
> >
> >> On Mar 17, 2023, at 3:04 AM, Mathias <[email protected]> wrote:
> >>
> >> OK, so I'm working on an apple script to replace Localizable (apple)
> comments on the /* ... */ format to <!-- and -->
> >>
> >> I got it working, but I'm using two commands because I couldn't figure
> the grep out... can this be simplified with only one "replace" ?
> >>
> >> pointers appreciated, script here:
> >>
> >> tell application "BBEdit"
> >> tell front text window
> >> replace "(/\\*[^\\*]*\\*/)" using "<!--\\1-->" options ¬
> >> {search mode:grep, case sensitive:false, starting at top:true}
> >> replace "(/\\*|\\*/)" using "" options {search mode:grep, case
> sensitive:false, starting at top:true}
> >> replace "%@" using "%1$s" options {case sensitive:false, starting at
> top:true}
> >>
> >> end tell
> >> end tell
> >>
> >> --
> >> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter: <
> https://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 [email protected].
> >> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/65afd9cc-0a86-4821-b302-20b2948c3cdcn%40googlegroups.com
> .
> >
> > --
> > This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter: <
> https://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 [email protected].
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/B37085B8-A95C-4105-B396-5E089AADFEFB%40cruzio.com
> .
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature
> request or need technical support, please email "[email protected]"
> rather than posting here. Follow @bbedit on Twitter: <
> https://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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/B4B02A99-8F77-4877-93AD-328302B74BBB%40cruzio.com
> .
>


-- 
Kaveh Bazargan PhD
Director
River Valley Technologies <http://rivervalley.io> ● Twitter
<https://twitter.com/rivervalley1000> ● LinkedIn
<https://www.linkedin.com/in/bazargankaveh/> ● ORCID
<https://orcid.org/0000-0002-1414-9098> ● @[email protected]
<https://mastodon.social/@kaveh1000>
*Accelerating the Communication of Research*

*
<https://rivervalley.io/gigabyte-wins-the-alpsp-scholarly-publishing-innovation-award-using-river-valleys-publishing-technology/>
<https://www.linkedin.com/posts/bazargankaveh_ismte-innovation-award-recipient-kaveh-bazargan-activity-7039348552526921728-XAEB/?utm_source=share&utm_medium=member_desktop>*

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/CAJ2R9pgTRLttsekBAWXHFUW7NUFRcH%2BbhOEjDpsr3axsXEQhGA%40mail.gmail.com.

Reply via email to