On Thu, Jan 24, 2013 at 09:51:25AM -0500, Adam Engst wrote:
> Man, you're going to make me learn perl grep syntax, aren't you? :-)
>
> I see roughly how to do it, and I can do simple substitutions in perl,
> but I'm having trouble getting the more complex ones to run. I've
> figured out that you need to dot-combine literal characters with grep
> in the replacements, but I'm getting SCALAR and some numbers instead
> of my grep replacements, and there's some distinction between /n and
> /r I'm not yet understanding (since things work better with \n than
> \r, but I always use \r in BBEdit).
>
> s/^Title: / '#' /e;
> s/^Blurb: (.+)/ 'A>' . \1/e;
> s/^(by.+)/ '_' . \1 . '_'/ie;
> s/^\*\*(.+)\*\* (-*)( *)/ '## ' . \1 . \r . \r/e;
/e is only necessary if you need to execute Perl code in the replacement.
If the replacement is just a string, you don't need it.
In the replacement, $1 is preferred over \1.
Perl uses \n to mean 'the native line-ending', so you should generally use
that instead of \r.
s/^Title: /#/;
s/^Blurb: (.+)/A>$1/;
s/^(by.+)/_${1}_/i;
s/^\*\*(.+)\*\* -* */## $1\n\n/;
By the way, the SCALAR followed by some numbers was caused by the
combination of /e and \1. \1 *as an expression* is a reference to the
scalar value 1. When you stringify a reference, you get the type followed
by the memory address.
Ronald
--
--
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 [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 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>