Hi, Chris!
On 30 Oct 2016, at 20:02, Christopher Stone wrote:
On Oct 30, 2016, at 12:54, Vlad Ghitulescu <[email protected]
<mailto:[email protected]>> wrote:
Any chance to extend the text filter with my 4th delete:
Try this:
#!/usr/bin/env perl -0777 -nsw
s! *\(Viewed\) *(?=[\n\r])!!ig;
s!\nVideo *! !ig;
s!^Save \w.+[\n\r]!!gm;
print;
Thanks, Chris, this worked completely - and reminded me that I wanted to
finally learn using RegEx! :-/
You should be close to being able to modify this for your own purposes
by now.
The canonical method of writing a search/replace in Perl is thus:
s/<search-pattern/<replace-pattern/<flags>;
But you can replace the forward-slashes with many different symbol
characters for flexibility and clarity.
I like to use the exclamation point myself.
So...
s!<search-pattern>!<replace-pattern>!<flags>;
The most common flags:
g == Match globally, i.e. find all occurrences
i == Case-insensitive
m == Treat string as multiple lines
s == Treat string as single line. (Make . match a newline)
While Perl ordinarily operates on text on a per-line basis, I've used
some tricks to make each search/replace line operate on the entire
text in the script above.
That is the "gm" in the Save-part respectively the "ig" for the others,
right?
So take this simple case and experiment with various regular
expressions.
#!/usr/bin/env perl -0777 -nsw
s!seach!replace!ig;
print;
Ok, I'll try it.
Thanks!
* Note that statements in Perl must be terminated with a semi-colon.
--
Take Care,
Chris
Until next time, Chris!
Vlad
--
This is the BBEdit Talk public discussion group. If you have a
feature request or would like to report a problem, please email
"[email protected]" 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/bbedit.