Re: Strip substring using do shell script and regex
Re: Strip substring using do shell script and regex
- Subject: Re: Strip substring using do shell script and regex
- From: Axel Luttgens <email@hidden>
- Date: Wed, 28 Dec 2016 17:17:13 +0100
> Le 28 déc. 2016 à 16:52, debt a écrit :
>
> I’m trying to strip a substring of 2 digits following an asterisk (e.g. *67 or *82, etc.) but I’m running into problems. Can someone see what I’m doing wrong here?
>
> set clean_text to do shell script "echo " & quoted form of original_name & " | perl -pe ’s/\*\d{2}//g;'"
>
> The regex works fine in Perl, so I’m not sure what’s wrong with the above.
Hello Marc,
You need to double the backslashes so that the AppleScript parser interpret them as a single backslash:
set original_name to "a*22b*44c"
set clean_text to do shell script "echo " & quoted form of original_name & " | /usr/bin/perl -pe 's/\\*\\d{2}//g;'"
--> "abc"
HTH,
Axel
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden