Replace on Different Line Than Find?

2010-11-01 Thread Warren Michelsen
Is it possible within BBEdit to do a Find getting text from one line and them 
do another find/replace to append the original found text to the second found 
line? I.e., can BBEdit hold found text for later use?

If not, then I need some Perl help. 

Within each file passed to the Perl script, I want to find the line beginning 
movieYear :  and get the four digits following the space and before the line 
end character.


^movieYear : (\d{4})

I need to append a space and the four digits (within parentheses) to the end of 
the line beginning title : 

So, if I call the Perl script:

/path/to/perl/script.pl /path/to/Phantom.txt /path/to/Kong.txt

and if the files passed to the script contain among their lines



Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera
more lines


Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong
more lines


I need the script to produce:


Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera (1925)
more lines


Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong (1933)
more lines


Anyone care to lend a hand?


-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: Replace on Different Line Than Find?

2010-11-01 Thread Warren Michelsen
At 7:58 AM -0700 11/1/10, Warren Michelsen sent email regarding 
Replace on Different Line Than Find?:
Is it possible within BBEdit to do a Find getting text from one line 
and them do another find/replace to append the original found text 
to the second found line? I.e., can BBEdit hold found text for later 
use?


If not, then I need some Perl help.



It looks like, in the files I need to process, the movieYear line 
always precedes the title line so that I can use BBEdit to:




Find:
(^movieYear : )(\d{4})((?s).+)(^title : )(.*$)

Replace
\1\2\3\4\5 \(\2\)

How would I express this particular find/replace in a Perl script?





Within each file passed to the Perl script, I want to find the line 
beginning movieYear :  and get the four digits following the space 
and before the line end character.


^movieYear : (\d{4})

I need to append a space and the four digits (within parentheses) to 
the end of the line beginning title : 


So, if I call the Perl script:

/path/to/perl/script.pl /path/to/Phantom.txt /path/to/Kong.txt

and if the files passed to the script contain among their lines



Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera
more lines


Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong
more lines


I need the script to produce:


Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera (1925)
more lines


Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong (1933)
more lines

Anyone care to lend a hand?



--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: Replace on Different Line Than Find?

2010-11-01 Thread Doug McNutt
!/usr/bin/perl
undef $/; # Tell perl to ignore line ends in the input.
$thetext = STDIN;  # read the whole document from standard input.
$e = \n;  # Make it clear which line ends your document has in it. You might 
want \r or \r\n.
# Do the substitutions (s///) using the s flag to include line ends and the g 
flag to repeat.
#begin single line that hopefully didn't get shortened by email.
$thetext =~ s/${e}movieYear : (\d\d\d\d)${e}(.*?)${e}title : ([\w 
]*?)${e}/${e}movieYear : $1${e}$2${e}title : $3 \($1\)${e}/sg;
#end single line
print $thetext;  # report the result to standard output.
__END__


Call perl like this.
perl -w filename.pl  filename.pl


Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera
more lines


Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong
more lines


-- 

-- From the U S of A, the only socialist country that refuses to admit it. --

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: Replace on Different Line Than Find?

2010-11-01 Thread Warren Michelsen
At 1:05 PM -0600 11/1/10, Doug McNutt sent email regarding Re: 
Replace on Different Line Than Find?:

!/usr/bin/perl
undef $/; # Tell perl to ignore line ends in the input.
$thetext = STDIN;  # read the whole document from standard input.
$e = \n;  # Make it clear which line ends your document has in it. 
You might want \r or \r\n.
# Do the substitutions (s///) using the s flag to include line ends 
and the g flag to repeat.

#begin single line that hopefully didn't get shortened by email.
$thetext =~ s/${e}movieYear : (\d\d\d\d)${e}(.*?)${e}title : ([\w 
]*?)${e}/${e}movieYear : $1${e}$2${e}title : $3 \($1\)${e}/sg;

#end single line
print $thetext;  # report the result to standard output.
__END__


I'm sure this will work splendidly, if only I knew what you were saying...

So, if I save the above script as TitleYear.pl and have two text 
files to process, Phantom.txt and Kong.txt, how, exactly, would I 
invoke it?



path/to/TitleYear.pl -w Phantom.txt Kong.txt

?






Call perl like this.
perl -w filename.pl  filename.pl

Phantom.txt
some text
More text
movieYear : 1925
additional lines of text
title : The Phantom of the Opera
more lines

Kong.txt
some text
More text
movieYear : 1933
additional lines of text
title : King Kong
more lines



--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: Is there a way to have BBEdit remember the window size and position?

2010-11-01 Thread GeoRud
Sorry, please ignore my question. I just found the answer. I was
looking in the place.

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Groups home page not loading

2010-11-01 Thread hcabbos
Loading this Google group's Home page isn't loading. At least not for
the few hours I've tried this Saturday morning.

http://groups.google.com/group/bbedit

The only way to get to discussions is to visit the discussions
overview page:

http://groups.google.com/group/bbedit/topics?start=

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Is there a way to have BBEdit remember the window size and position?

2010-11-01 Thread GeoRud
I have three monitors. When I open BBEdit I would like it to go to a
specific monitor and to a specific position on that montior. Is this
possible?

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: [ANN] BBEdit 9.6.1 (2845) pre-release

2010-11-01 Thread Walter Ian Kaye
At 05:01 p -0400 10/29/2010, Rich Siegel didst inscribe upon an 
electronic papyrus:



*   [193877] Fixed a bug which would cause a crash while editing in
some situations (which themselves are not clearly understood, nor
reproducible).


You fixed a non-reproducible bug? Wow.
Next thing we know, you'll be announcing breakfast at Milliway's. :)


-boo

--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: Replace on Different Line Than Find?

2010-11-01 Thread Doug McNutt
At 14:27 -0700 11/1/10, Warren Michelsen wrote:
At 1:05 PM -0600 11/1/10, Doug McNutt sent email regarding Re: Replace on 
Different Line Than Find?:
!/usr/bin/perl
undef $/; # Tell perl to ignore line ends in the input.
$thetext = STDIN;  # read the whole document from standard input.
$e = \n;  # Make it clear which line ends your document has in it. You 
might want \r or \r\n.
# Do the substitutions (s///) using the s flag to include line ends and the g 
flag to repeat.
#begin single line that hopefully didn't get shortened by email.
$thetext =~ s/${e}movieYear : (\d\d\d\d)${e}(.*?)${e}title : ([\w 
]*?)${e}/${e}movieYear : $1${e}$2${e}title : $3 \($1\)${e}/sg;
#end single line
print $thetext;  # report the result to standard output.
__END__

I'm sure this will work splendidly, if only I knew what you were saying...

So, if I save the above script as TitleYear.pl and have two text files to 
process, Phantom.txt and Kong.txt, how, exactly, would I invoke it?

path/to/TitleYear.pl -w Phantom.txt Kong.txt

***

 I confess that I don't know how BBEdit currently handles filters that run in 
perl.  I'm stuck on Mac OS neXt 10.3.9 because I refuse to give up my SE/30 
file server that needs Apple file sharing over ethernet. The result is that I'm 
way behind in BBEdit versions. (Confession:  I really like gedit under Ubuntu 
Linux. What I don't like I can change!)

If you use an ordinary Terminal session with the perl code named as you 
indicate you would first make sure your working directory is set with chdir and 
then enter:

perl -w  TitleYear.plPhantom.txt
# -   and later. . .
perl -w  TitleYear.plKong.txt

The  redirection operator tells the shell to use the file following it to be 
given to the perl filter as standard input. The results are being sent to 
standard output which will appear on the lines below your command in the shell. 
You could copy and paste them into BBEdit but I'm pretty sure there is a way to 
do that within BBEdit so that it replaces the content of an open file. Can 
someone help with that?

You could also do something like:
perl   TitleYear.plPhantom.txtFixedFiles.txt
perl   TitleYear.plKong.txt   FixedFiles.txt

which would redirect the first line's output to a new file FixedFiles.txt and 
add the second lines output to the file created by the first.

You shouldn't need the -w flag in the call to perl after you're satisfied that 
the code runs without error. It's just asking that warnings be displayed.

cat is the UNIX tool that concatenates files. Another option would be:

cat Phantom.txt  Kong.txt | perl  TitleYear.pl  Concatenated.txt

The | (pipe) operator says to pass the output of the cat program to the new 
perl tool as standard input.

You could also modify the perl code to pick up a list of files such as 
everything in the current directory that ends with .txt. That would involve 
looping over a list of arguments while running print statements to a single 
output file. That's a bit like your pathto line above.  Untested, because I'm 
preparing this on a Mac 8500 running OS 9, 

while (@argv)
{
$nextfile = shift @argv;  #get the next file in the list of arguments
open IN, $nextfile;
$thetext = IN;
#  do the above work as on a single file
print $thetext;
{

Your pathto line would be assuming that  TitleYear.pl is executable. The 
shebang (#!) line can make that work but you'll have to set the x permission on 
the perl file to make it work.

chmod +x  path/to/TitleYear.pl

is the appropriate shell  command.

perl is not so hard to learn. It helps if you know some C but learning perl can 
help make you into a C programmer. Lots of books and internet content are 
available.
-- 

--  Halloween  == Oct 31 == Dec 25 == Christmas  --

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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


Re: BBEdit 9.6.1 (2845) pre-release

2010-11-01 Thread Steve Piercy
On Oct 30, 8:15 pm, Walter Ian Kaye boodl...@gmail.com wrote:
 At 05:01 p -0400 10/29/2010, Rich Siegel didst inscribe upon an
 electronic papyrus:

 *   [193877] Fixed a bug which would cause a crash while editing in
      some situations (which themselves are not clearly understood, nor
      reproducible).

 You fixed a non-reproducible bug? Wow.

Yup. Since installing this fix, I have not been able to reproduce the
irreproducible.
http://groups.google.com/group/bbedit/msg/4be6647ae26f658a?hl=en

 Next thing we know, you'll be announcing breakfast at Milliway's. :)

They'll have to believe in five other things before breakfast, first.

--steve

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
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