On Mon, Aug 17, 2009 at 04:24:43AM -0700, xbsjason wrote:
> 
> Hey guys, I hate to reply to my own post for fear of spamming but I
> was hoping someone had the time to take a look at my initial questions
> above, as I'm still at a standstill. 8(
> 
> On Aug 7, 12:11?pm, xbsjason <[email protected]> wrote:
> > Hello all,
> >
> > My question is two-fold. I finally figured out agrepsearch and
> > replacepatternthat suits my needs. Its a really simple one, but a
> > huge step forward for me.
> >
> > SEARCHGREP
> > ^([^\t]+)\t([^\t]+)$
> >
> > REPLACE WITH
> > \2.\rNote: \1\r
> >
> > So my question is this... Is it possible to create a replacepattern
> > that will change the case for \2 to Capitalized case, but only if the
> > included words are 4 or more letters? As an example I have this:
> >
> > Model1495 \t Base cabinet, hardware, and related accessories
> >
> > Which, when run through mygrepsearch and replace becomes this:
> >
> > Base cabinet, hardware, and related accessories.
> > Note: Model1495
> >
> > But I'd like it to become this (note the capitalized case for words 
> > inpattern2 longer than 4 characters):
> >
> > Base Cabinet, Hardware, and Related Accessories.
> > Note: Model1495
> >
> > Is this possible?

It is not possible to do this with just a simple Grep search.  You could do
this with a filter, however.  Here's one written in Perl:

#!perl -pl

s{^([^\t]+)\t([^\t]+)$}
 { my($note, $title) = ($1, $2); $title =~ s/(\S{4,})/\u$1/g;
   "$title.\nNote: $note" }ge;

__END__


Although since we're in Perl, instead of nested substitutions we could just
use split:

#!perl -nl

my ($note, $title) = split /\t/;
$title =~ s/(\S{4,})/\u$1/g;
print "$title.\nNote: $note";

__END__


> > Next question, if I have a list of item names, can I quickly create a
> > text file for each of them?
> >
> > Say my list is simple each item on a new line like so...
> >
> > Item 1
> > Item 2
> > Item 3
> >
> > and I want Item1.txt, Item2.txt, Item3.txt
> >
> > Thanks for the time.

I don't know if there's a built-in feature in BBEdit to do this.  Here's
a very simple Perl script:

#!perl -nl

s/\s+//g;
open (my $fh, '>>', "$_.txt")
  or die "Can't open $_.txt: $!\n";

This opens each file in append mode, so it won't overwrite any files that
already exist.  Although it removes whitespace, it does not verify that the
filename is actually valid.

HTH,
Ronald

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "BBEdit Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to "[email protected]" 
rather than posting to the group.
-~----------~----~----~----~------~----~------~--~---

Reply via email to