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>

Reply via email to