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

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

Re: Regex to match "define ABC-123-xyz"


From: David Kastrup
Subject: Re: Regex to match "define ABC-123-xyz"
Date: Wed, 08 Dec 2010 15:30:33 -0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Gary <help-gnu-emacs@garydjones.name> writes:

> I'm having trouble with this, to say the least. "Obviously" the parts
> after the define aren't fixed, either in content or position. What I
> have tried is
>
> define [A-Za-z0-9_-]+
>
> (that is, match the string "define", followed by a single space,
> followed by some string consisting of letters and numbers plus "_" and
> "-") which works except... it doesn't match the numeric part(s). I can
> see this in the regexp builder, and, since I am attempting to match part
> of a programming language syntax, in source code. Kind of
> confusing. What have I done wrong, please?

I don't see your problem.  Care to give a reproducible recipe?

If I do

M-: (progn (string-match "define [A-Za-z0-9_-]+" "define ABC-123-xyz") 
(match-end 0))

I get 18, as expected.

-- 
David Kastrup


reply via email to

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