help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regex Problem


From: Thr4wn
Subject: Re: Regex Problem
Date: Mon, 21 Jul 2008 14:47:00 -0700 (PDT)
User-agent: G2/1.0

On Jul 19, 1:50 pm, travis jeffery <eatsleepg...@gmail.com> wrote:
> I'm trying to write and extension for using tumbr. In tumblr there are two
> requirements for a post; title and body.
>
> So I set up a tumblr post document as:
> title:
> body:
>
> So get the title I use (string-match "\\title: \(.*\)\$"), which is fine
> because it's on a single line. But with I'm having trouble getting the body
> because it's multiple lines. So is there someway I can get any text
> following the body:_space_? I was thinking also of saving the entire buffer
> and then subtracting the title: TITLE and body:_space_ but I still don't
> know about that.
>
> Thanks for your help.
> --
> View this message in 
> context:http://www.nabble.com/Regex-Problem-tp18547090p18547090.html
> Sent from the Emacs - Help mailing list archive at Nabble.com.

In an emacs regexp, you can directly enter a newline character as a
possible match by hitting C-j (will appear as ^J in the regexp) and/or
C-q C-m (honestly, I'm not exactly sure what the difference between ^J
and ^M is. I think one is \n while the other is \r. Since Windows
requires all lines to end with \r\n, I would allow for either ^J or ^M
in the search).

Also, \' means "end of buffer/string", so using both that knowledge, I
think the following will work...

"^body: ?\(\(.\|^J\|^M\)*\)\'"      (there is a \' at the end of that
string)

Also, I am not certain if I understand why your regexp for title had \
\ at the beginning? wouldn't that match a literal backslash when you
really want just the beginning of the line (^)?

let me know if something I said didn't make sense.

-Thr4wn


reply via email to

[Prev in Thread] Current Thread [Next in Thread]