Guys, thanks a bunch for great feedback! I will take your stuff and make it 
work i'm sure. If not i'll bother you here again! :) The reason for me 
taking AppleScript is that i was doing stuff before i had BBEdit and i 
kinda knew it, that's all.

On Thursday, October 15, 2020 at 3:26:55 PM UTC+2 John R M. Delacour wrote:

>
>
> On 13 Oct 2020, at 06:54, Mathias af Jochnick <mat...@lightlabs.se> wrote:
>
> i'm trying to make 2 scripts to convert between IOS and Android i18n 
> formats to work. I've gotten Android -> IOS to work, but the other way 
> around is a challenge.
>
> Basically, for each row in a file i want to convert
> *"login_infoLabel" = "Do you need help? Press here.”;*
> to
> *<string name="login_infoLabel">Do you need help? Press here.</string*
>
> See my script below. The problem is the first search string to find the 
> first " on each row. I spoke with Patrik at BBEdit and he kindly informed 
> me that it was because AppleScript doesn't support grep
>
>
> Patrick could not be more right!  AppleScript is not the tool for text; 
> but BBEdit provides the Text Factory feature that allows you to use Perl 
> (or Python, or sed) to do the work easily.
>
> Here is your script written in Perl:
>
> #! /usr/bin/perl
> while (<>) {
> # changes quotes round string name to §, preserving them
> s~"(login_infoLabel)" ?= ?([^;]+);~<string name=§$1§>$2</string>~g;
> # delete the quotes not preserved
> s~"~~g;
> # restore the quotes round string name
> s~§~"~g;
> # remove the final semicolon
> s~;$~~;
> # Execute the substitutions
> print;
> }
>
> This script will operate on the front window.
>
> How to do it—
> 1. Open a new Text Factory (Menu: File::New...), paste in the above 
> script, and save it as test.pl in
> ~/Library/Application Support/BBEdit/Text Filters/
> 2. Open the (Menu: Window::Palettes::)Text Filters palette
> 3. Set a shortcut of you like
> 4. Run the script (filter) with your target window frontmost.
>
> Notes—
> I use "~" in the regex rather than "/".  You can use whatever you like.
> s~found~replacement~g ;  #~g means replace all
> Perl Regular Expressions differ from BBEdit's PRE in using $1, $2 etc 
> rather than \1, \2
> All the Perl knowledge you need to make the filter is:
> a valid shebang line (should not be necessary and was not in better days!);
> the while loop: while (<>) { ...... } ;
> a knowledge of regex in Perl, which is almost the same as BBEdit's 
> implementation but more powerful.
>
> JD
>
>
>
>
>
>

-- 
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: <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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/1c77b703-3885-407d-9fcb-78f9e3113c61n%40googlegroups.com.

Reply via email to