Re: Find and Replace help please

2018-05-18 Thread Matthew London
Hi Again,

Turns out there are sometimes multiple lines both within my KEEP text and 
in my DELETE text.

le:
&&&
Line or Lines to be KEPT
###
Line or Lines to be DELETED
&&&
Line or Lines to be KEPT
###
etc.

Grateful for your help

On Wednesday, May 2, 2018 at 12:51:20 PM UTC-7, Kerri Hicks wrote:
>
> Use the Find dialog and turn on the "Grep" switch...
>
> 1) I have questions about this one. Are the lines to be kept and the lines 
> to be deleted always alternating? (e.g. there's always one to be kept, 
> always followed by one and only one to be deleted?) If not, I'd probably do 
> this one in two steps (first delete the hash lines and the deletable lines, 
> and then just go through and delete all the ampersands, so, use the same 
> expression as #2, and then do another search and replace for &&&\n). (And I 
> just saw that Sam mentions the same strategy. I started this email an hour 
> ago.)
>
> 2) ###\n.*?\n
>
>>
>>


 

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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: Another Newbie GREP help request...

2018-05-18 Thread Matthew London
I think I see my problem.
I was using "Process Lines Containing" which appears to extract the entire 
line, not matter what I search for.
I used Search with the Extract function, and it works now! 

Thank you


On Friday, May 18, 2018 at 1:47:33 AM UTC-7, Rick Gordon wrote:
>
> Change the .* in your string to [^.]* 
>
> (And you don't need the square brackets around \. ) 
>
> So: 
> from [A-Z][a-zA-Z][^.]*\. 
>
> …which really means: 
>
>  from followed by a space 
>
>  a single capital letter, not including diacriticals/accents 
>
>  a single letter of any case, not including diacriticals/accents 
>
>  any number (including zero) of non-period characters (which may 
> include other punctuation, spaces, line breaks, etc.) 
>
>  a period 
>
> Does that work, or do you need to be more specific? 
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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: Find and Replace help please

2018-05-04 Thread Matthew London
Thank you Chris, Kerri and Sam.
Got what I need. Much appreciated.

On Thursday, May 3, 2018 at 10:16:36 PM UTC-7, Christopher Stone wrote:
>
> On 05/02/2018, at 12:25, Matthew London <mlo...@gmail.com > 
> wrote:
>
> I have a file with the following:
>
> &&&
> TEXT STRING I WANT TO KEEP
> ###
> TEXT STRING I WANT TO DELETE
> &&&
> TEXT STRING I WANT TO KEEP
> etc,
>
>
> Where there is a linebreak after &&&, ###, and all text strings
>
> --
>
> Hey Matthew,
>
> You weren't clear about whether your source text contains strings other 
> than &&&…keep and ###…delete, so for the moment I'll assume these two types 
> are the only content in the file.
>
> --
>
> For information on installing and using BBEdit's text filters see (here 
> <http://www.bbeditextras.org/wiki/index.php?title=Text_Filters>).
>
> --
>
> This text-filter removes all but your *keep* text.  It does this by 
> finding your keep symbol and printing the following line.
>
> #!/usr/bin/env bash
> sed -En '/^&&&/{n;p;}' # Print next line after found regex.
>
> --
>
> This text-filter prints the *keep* symbol and the following line.
>
> #!/usr/bin/env bash
> sed -En '/^&&&/,/[^[:blank:]]/{p;}' # Print found Regex and the next line 
> after it.
>
> --
>
> Sed is very quick and efficient for this sort of job, but it's not the 
> only game in town.
>
> --
>
> This text-filter uses egrep to find the regex and the line after it.  It 
> then uses sed to delete any record separators “--” egrep places between 
> found records.
>
> #!/usr/bin/env bash
>
> egrep -i -A1 "^&&&" | sed -E '/^--/d'
>
> Output:
>
> &&&
> TEXT STRING I WANT TO KEEP
> &&&
> TEXT STRING I WANT TO KEEP
>
> --
>
> We can build on the above and also delete the *keep* symbol.
>
> #!/usr/bin/env bash
>
> egrep -i -A1 "^&&&" | sed -E '/^(--|&&&)/d'
>
> Output:
>
> TEXT STRING I WANT TO KEEP
> TEXT STRING I WANT TO KEEP
>
> --
>
> Lastly I'll trot out the 900lb gorilla — Perl.
>
> #!/usr/bin/env perl -sw
>
> while (<>) {
> print if $,; $, = /^&&&/
> }
>
> Output:
>
> TEXT STRING I WANT TO KEEP
> TEXT STRING I WANT TO KEEP
>
> --
>
> #!/usr/bin/env perl -sw
>
> while (<>) {
> print if /^&&&/;
> print if $,; $, = /^&&&/
> }
>
> Output:
>
> &&&
> TEXT STRING I WANT TO KEEP
> &&&
> TEXT STRING I WANT TO KEEP
>
> --
>
> --
> Best Regards,
> Chris
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: <http://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.


Find and Replace help please

2018-05-02 Thread Matthew London
Hi,
I have a file with the following:


&&&
TEXT STRING I WANT TO KEEP
###
TEXT STRING I WANT TO DELETE
&&&
TEXT STRING I WANT TO KEEP
etc,
where there is a linebreak after &&&, ###, and all text strings


I need to process this text in two different ways;

1) 
I would like to remove ALL of the following:
###
TEXT STRING I WANT TO DELETE
&&&


So the result is:
TEXT STRING I WANT TO KEEP
TEXT STRING I WANT TO KEEP
TEXT STRING I WANT TO KEEP



2) 
I would like to remove ONLY the following:

###
TEXT STRING I WANT TO DELETE

So the result is:

&&&
TEXT STRING I WANT TO KEEP
&&&
TEXT STRING I WANT TO KEEP
&&&
TEXT STRING I WANT TO KEEP
etc.

Grateful for suggestions on how to do this.
Thank you.

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, 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.