[lug] XEmacs quoting madness!

Walter Pienciak walter at frii.com
Mon Aug 20 12:59:26 MDT 2001


On 20 Aug 2001, Tkil wrote:

> if you're doing anything with regexps, you have to remember that
> backslashes are special inside emacs' (and most other) regexps.  so,
> you want the "true value" to be a doubled backslash -- the backslash
> is the quote/escape character, so you need to quote/escape it to get a
> literal backslash.  so you end up doing things like this:
>
>   (while (re-search-forward "Can\\\\'t" (point-max) t)
>      ...)
>
> just as an aside, this is a place where you really start noticing the
> tradeoffs between regular, consistent, easy-to-parse languages (like
> lisp, python, tcl) and nasty, irregular, special-case-all-over-the-
> place languages (like perl).

Heyyyyyy, Tony . . . I resemble that remark.

Anyway, I dunno if the nasty part refers to Perl regexes (no argument
here -- they can give me headaches to look at, though they are pretty
powerful) or the language's syntax flexibility (feature or a bug, you
decide) to the escaping-from-hell stuff, which I avoid by using the
qq & friends syntax.  That is, instead of

    print "\"Foo!\"";  #  prints "Foo!"

I'd use

    print qq{"Foo!"};  #  prints "Foo!"

If this area is of any interest, it's all covered in the perlop manpage
in the "Quote and Quote-like Operators" section, including some
pattern and regex stuff.

In any case, it's all the fault of those backslashin' maniacs
at Bell Labs and their band of fawning sycophants.  Yeah, that's it...

Walter "I say q{Tomato}."






More information about the LUG mailing list