Re: Possible with Grep?

2024-02-28 Thread Mike Pasini
I did this once upon a time but had to use separate replacements for each 
case pattern. Here's an example you can run in BBEdit:

#!/usr/bin/env perl

@data = ( "word","Word","WORD");

$mask = "%-10s >> %s\n";

for $datum (@data) { 
printf $mask, $datum, fix($datum);
print "\n";
}

sub fix {
local $_ = shift;
s/\b[a-z]+?\b/something/g;
s/\b[A-Z][a-z]+?\b/Something/g;
s/\b[A-Z]+?\b/SOMETHING/g;
return $_;
}

On Wednesday, February 28, 2024 at 9:38:23 AM UTC-8 Jim Straus wrote:

> Hello all regex experts -
>   I'm looking to change a word in my code to another one, but it is 
> sometimes "Word", "word" or "WORD".  I can do this with three search and 
> replaces.  I also know about the \u\U modifications to the group (so \u\1 
> to uppercase the first letter), but that doesn't really work, since I'm 
> changing the word (not using the group).  What I think I want is something 
> that would take just the case of the matched group and apply that to 
> replacement text.  Or is there another way to accomplish this in one 
> pattern?
>   Thanks!
> -Jim Straus
>

-- 
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: 
--- 
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/91235356-f030-4e14-8efc-f3995525b29an%40googlegroups.com.


Re: Need Grep Pattern

2024-02-15 Thread Mike Pasini
Let's describe the pattern you are trying to split. There's more than one 
way to do that (as the replies to you query show) but by focusing on a 
general pattern (what must always be true about your original text), we can 
make a more reliable regexp.

You want to capture everything up to the first space -- ^(.+?)/s -- 
followed by just about anything (.+?)/s until you see a string of numbers 
including a period ([\d.]+?)$ at the end of the line.

So try: ^(.+?)\s(.+?)\s([\d.]+?)$

In BBEdit, you can put that in the Find dialog with \1\n\2\n\3\n\n in the 
replace to make the three groups clear (substitute \t for the first \n for 
tabs).

On Wednesday, February 14, 2024 at 3:05:25 PM UTC-8 Kim Mosley wrote:

I want to add tabs (or something else that might be better) so that I can 
have three columns… date, vendor with city, and price.

Can someone help?

Thanks!

01/03/23 CENTRAL MARKET 61 AUSTIN, TX 45.00
01/04/23 H-E-B 425 AUSTIN, TX 74.62
01/09/23 CENTRAL MARKET 61 AUSTIN, TX 43.70
01/10/23 WHOLEFDS LMR 10145 AUSTIN, TX 62.25
01/13/23 SQ *ASAHI IMPORTS Austin, TX 24.46
01/14/23 CENTRAL MARKET 61 AUSTIN, TX 29.22
01/17/23 CENTRAL MARKET 61 AUSTIN, TX 28.25
01/18/23 CENTRAL MARKET 61 AUSTIN, TX 19.34
01/21/23 CENTRAL MARKET 61 AUSTIN, TX 1.83
01/21/23 CENTRAL MARKET 61 AUSTIN, TX 18.34
01/23/23 CENTRAL MARKET 61 AUSTIN, TX 19.85

-- 
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: 
--- 
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/2e4a77ba-e50f-46b8-877b-59f0e08cef0en%40googlegroups.com.


Re: AppleScript to upload front-displayed file to correct location via FTP?

2019-06-20 Thread Mike Pasini
I use a Keyboard Maestro palette full of scripts based on the Execute Shell 
Script action to upload and refresh files on my site. The approach is 
different for uploading a new directory of files and for uploading a single 
file but both rely on the built-in Unix utility curl to do the dirty work.

Some of the scripts prompt me for a file, others know which file to refresh 
but the current Finder selection would work too.

You'd use the Do Shell Script command to run curl within AppleScript.

On Thursday, June 20, 2019 at 10:06:04 AM UTC-7, Fabrizio Ferrari wrote:
>
> Hello everyone.
>
> I'd need to create an AppleScript that allows me to simply upload 
> automatically the front-displayed file saved on my local hard disk to a 
> remote server in its correct location. The local directory structure 
> matches the remote directory structure, so that should be pretty easy to 
> setup.
>
> Has anyone already created such a script or has any suggestions about it?
>
> Thanks in advance to everyone.
>
>
>

-- 
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 to the group.
Follow @bbedit on Twitter: 
--- 
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 post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/1cbf9e41-6e4c-42d4-ad67-016d3566e76a%40googlegroups.com.


Re: Tricky regex question

2019-02-02 Thread Mike Pasini


On Saturday, February 2, 2019 at 9:45:40 AM UTC-8, jgill wrote:
>
> I need to identify chord lines and non-chord lines so that I can style 
> them differently on a web page. Remember, I'm not just looking for [A-G] 
> but A7, Am, A#, A♭dim etc
>
>
Yep, it's tricky. This (https://regex101.com/r/xQ5vd6/4) works on your 
example text (surrounding chords with bold HTML tags) but will fail on any 
lyric line that begins with anything from A to G. And it doesn't handle the 
more complex chord designations (like flats).

Which would suggest the best approach would be a little Perl script you 
could access as a Text Filter in BBEdit that would just look at 
odd-numbered lines (assuming the chords are first in the selection) and add 
the HTML formatting where a chord is found, no doubt using several regexes, 
looking for the longer, more complex strings first.

-- 
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 to the group.
Follow @bbedit on Twitter: 
--- 
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 post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Noob trying to improve on these grep / expressions

2018-12-31 Thread Mike Pasini
Yes, Perl is installed on OS X and you can extend its functionality with 
modules like the one I mentioned. But you do have to write code to create a 
BBEdit Text Filter (although not much more than what the module's example 
shows). You can find the Apple Text Filter option under the Text menu item 
in BBEdit and you can even edit those examples. But I understand that's a 
big leap to make.

On Monday, December 31, 2018 at 12:03:15 PM UTC-8, Dj wrote:
>
>  Mike, that makes a lot more sense now. I looked at page for the Module 
> and it seems it's run from terminal and OSX has perl pre-installed? Or is 
> it a "module" than can be run somehow from within BBedit? Thanks for the 
> patience, I'm not really a programmer, just want to look at questions posed 
> from my journal entries over time.  
>
> On Monday, December 31, 2018 at 6:46:24 AM UTC-8, Mike Pasini wrote:
>>
>> Dj, Process Lines processes *lines* not sentences. So any paragraph that 
>> has a sentence with a question mark in it would match searches for strings 
>> with question marks.
>>
>> Identifying a sentence is not a simple task. But there's a Perl module 
>> <https://metacpan.org/pod/Lingua::EN::Sentence> to help with that. Using 
>> that in a Text Filter would be my approach.
>>
>> On Saturday, December 29, 2018 at 1:54:37 PM UTC-8, Dj wrote:
>>>
>>>  Hello,  I'm trying to extract every sentence that ends with a question 
>>> from some text files. I'm using the old text wrangler -> process lines ->  
>>> copy to new document, but I'm still getting a lot of sentences that don't 
>>> end in question marks in that new text.
>>>
>>> I've come up with these two expressions, 
>>>
>>>(?:^|\.|\!|\?) ?\K.+?\?
>>>
>>> Then the next I tried: [^.!?]+\?
>>>
>>> Can someone see how these can be improved on?  
>>>
>>

-- 
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 to the group.
Follow @bbedit on Twitter: <https://www.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 post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Noob trying to improve on these grep / expressions

2018-12-31 Thread Mike Pasini
Dj, Process Lines processes *lines* not sentences. So any paragraph that 
has a sentence with a question mark in it would match searches for strings 
with question marks.

Identifying a sentence is not a simple task. But there's a Perl module 
 to help with that. Using 
that in a Text Filter would be my approach.

On Saturday, December 29, 2018 at 1:54:37 PM UTC-8, Dj wrote:
>
>  Hello,  I'm trying to extract every sentence that ends with a question 
> from some text files. I'm using the old text wrangler -> process lines ->  
> copy to new document, but I'm still getting a lot of sentences that don't 
> end in question marks in that new text.
>
> I've come up with these two expressions, 
>
>(?:^|\.|\!|\?) ?\K.+?\?
>
> Then the next I tried: [^.!?]+\?
>
> Can someone see how these can be improved on?  
>

-- 
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 to the group.
Follow @bbedit on Twitter: 
--- 
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 post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.