all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ken <gebser@mousecar.com>
To: PJ Weisberg <pjweisberg@gmail.com>
Cc: GNU Emacs List <help-gnu-emacs@gnu.org>
Subject: Re: RE for any text, including white space
Date: Wed, 16 Mar 2011 19:43:22 -0400	[thread overview]
Message-ID: <4D814B1A.1050103@mousecar.com> (raw)
In-Reply-To: <AANLkTinb1QWHxnEpKebLw69-mvWtK-Rqi4zoVnO_YJ7x@mail.gmail.com>


On 03/16/2011 06:05 PM PJ Weisberg wrote:
> On Wed, Mar 16, 2011 at 2:53 PM, ken <gebser@mousecar.com> wrote:
>> On 03/16/2011 03:40 PM PJ Weisberg wrote:
>>> On 3/16/11, ken <gebser@mousecar.com> wrote:
>>>> What's the RE for any text, white space included?  I also want to grab
>>>> (for match-string...) this text.  The text is bounded by known
>>>> characters.  E.g.,
>>>>
>>>> <h3>Any Text-- <a name="thisname">
>>>> Hot Stuff</h3
>>>> In the above, how to grab the text of the title, i.e., everything
>>>> between <h3> and </h3>?  Conceivably this title text might contain
>>>> *anything* except "</[Hh]{1-9]".
>>>>
>>> If A and B are your start and end points, then you want:
>>>
>>> "A\\(.\\|\n\\)*?B"
>> That's almost it, but not quite.  It grabs only the on last character
>> before the "B"; in my example above it grabs just "f".  I'm needing to grab:
>>
>> "Any Text-- <a name="thisname">
>> Hot Stuff"
>>
>> -- without the quotes, of course.
> 
> Well, it *matches* the whole thing; it's just that the parentheses
> only grab the last character.  Put in another set of parentheses
> around the part you want to capture, and you're golden.
> 
> "<h3>\\(\\(.\\|\n\\)*?\\)</h3"
> 
> -PJ

Cool.  That worked!!  PJ, you're /The Man/.

Somewhere in the many docs on REs I read it said that you couldn't nest
match syntax-- \\(...\\) so I never tried what you did.  Doing a lot of
different \\([...]*\\) kind of stuff didn't work (even with more '\'s)
at all.  So this was kind of a big learn.

Thanks much,
Ken



  reply	other threads:[~2011-03-16 23:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-16 13:23 RE for any text, including white space ken
2011-03-16 19:40 ` PJ Weisberg
2011-03-16 21:53   ` ken
2011-03-16 22:05     ` PJ Weisberg
2011-03-16 23:43       ` ken [this message]
2011-03-17  4:50     ` Kevin Rodgers
2011-03-17 10:20       ` ken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D814B1A.1050103@mousecar.com \
    --to=gebser@mousecar.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=pjweisberg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.