all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Regex to match "define ABC-123-xyz"
@ 2010-10-01 12:10 Gary
  2010-10-01 12:18 ` Deniz Dogan
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Gary @ 2010-10-01 12:10 UTC (permalink / raw)
  To: help-gnu-emacs

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?




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:10 Gary
@ 2010-10-01 12:18 ` Deniz Dogan
  2010-10-01 13:45   ` Gary
  2010-10-01 12:48 ` Tyler Smith
  2010-10-01 12:58 ` Tim Visher
  2 siblings, 1 reply; 12+ messages in thread
From: Deniz Dogan @ 2010-10-01 12:18 UTC (permalink / raw)
  To: help-gnu-emacs

2010/10/1 Gary <help-gnu-emacs@garydjones.name>:
> 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?
>

Pardon me if I misunderstood, but it works perfectly fine for me in
re-builder. Are you saying it works for you in re-builder but not when
actually using it in code?

-- 
Deniz Dogan



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
       [not found] <mailman.0.1285935054.30433.help-gnu-emacs@gnu.org>
@ 2010-10-01 12:20 ` Marc Mientki
  2010-10-01 12:26 ` David Kastrup
  1 sibling, 0 replies; 12+ messages in thread
From: Marc Mientki @ 2010-10-01 12:20 UTC (permalink / raw)
  To: help-gnu-emacs

Am 01.10.2010 14:10, schrieb Gary:
> 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).

Here (GNU Emacs 23.2.1 (i386-mingw-nt5.1.2600) of 2010-05-08 on G41R2F1) 
everything works as expected:
M-C-s define [A-Za-z0-9_-]+
matches entire "define ABC-123-xyz".

regards
Marc



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
       [not found] <mailman.0.1285935054.30433.help-gnu-emacs@gnu.org>
  2010-10-01 12:20 ` Regex to match "define ABC-123-xyz" Marc Mientki
@ 2010-10-01 12:26 ` David Kastrup
  1 sibling, 0 replies; 12+ messages in thread
From: David Kastrup @ 2010-10-01 12:26 UTC (permalink / raw)
  To: help-gnu-emacs

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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:10 Gary
  2010-10-01 12:18 ` Deniz Dogan
@ 2010-10-01 12:48 ` Tyler Smith
  2010-10-01 13:42   ` Gary
  2010-10-01 12:58 ` Tim Visher
  2 siblings, 1 reply; 12+ messages in thread
From: Tyler Smith @ 2010-10-01 12:48 UTC (permalink / raw)
  To: help-gnu-emacs

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 works for me. Maybe you've got a typo somewhere?





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:10 Gary
  2010-10-01 12:18 ` Deniz Dogan
  2010-10-01 12:48 ` Tyler Smith
@ 2010-10-01 12:58 ` Tim Visher
  2010-10-01 13:59   ` Erik L. Arneson
       [not found]   ` <mailman.4.1285942809.2643.help-gnu-emacs@gnu.org>
  2 siblings, 2 replies; 12+ messages in thread
From: Tim Visher @ 2010-10-01 12:58 UTC (permalink / raw)
  To: help-gnu-emacs

Hi Gary,

On Fri, Oct 1, 2010 at 8:10 AM, Gary <help-gnu-emacs@garydjones.name> wrote:
> 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?

Don't really understand what's going on.  I type the following into
scratch and use `M-x regex-builder` and it works exactly as I believe
you want it to.

*scratch* contents

define thisIs01Test_with-all_validChars0001

*RE-Builder* contents

define [A-Za-z0-9_-]+

Full match…

Could you provide an actual example of a string you're trying to match
that it isn't matching?

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:48 ` Tyler Smith
@ 2010-10-01 13:42   ` Gary
  0 siblings, 0 replies; 12+ messages in thread
From: Gary @ 2010-10-01 13:42 UTC (permalink / raw)
  To: help-gnu-emacs

Tyler Smith wrote:
> Gary 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 works for me. Maybe you've got a typo somewhere?

How odd - yeah, it's working for me now, at least in the R-E
Builder.




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:18 ` Deniz Dogan
@ 2010-10-01 13:45   ` Gary
  2010-10-01 15:23     ` rasmith
  0 siblings, 1 reply; 12+ messages in thread
From: Gary @ 2010-10-01 13:45 UTC (permalink / raw)
  To: help-gnu-emacs

Deniz Dogan wrote:
> 2010/10/1 Gary:
>> 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_-]+
...
>> 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.

> Pardon me if I misunderstood, but it works perfectly fine for me in
> re-builder. Are you saying it works for you in re-builder but not when
> actually using it in code?

It now works okay in the RE-Builder for me too, but not in the mode I
have written. I imagine the REs for different parts of the language are
getting in the way of each other somewhere. I will try removing some
until I get something that works and go on from there...




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 12:58 ` Tim Visher
@ 2010-10-01 13:59   ` Erik L. Arneson
       [not found]   ` <mailman.4.1285942809.2643.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 12+ messages in thread
From: Erik L. Arneson @ 2010-10-01 13:59 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 594 bytes --]

On Fri, 01 Oct 2010, Tim Visher wrote:
> Don't really understand what's going on.  I type the following into
> scratch and use `M-x regex-builder` and it works exactly as I believe
> you want it to.

I love this group!  I didn't even know about `regexp-builder', and now
I'm crazy about it.  Thank you.

Holy crap, that function is going to make my life easier.

-- 
Erik Arneson <dybbuk@LNouv.com>
  GPG Key ID : 1024D/62DA1D25   BitCoin : 1LqvuGUqJ4ZUSoE7YE9ngETjwp4yZ2uSdP
      Office : +1.541.291.9776    Skype : callto://pymander
            http://www.leisurenouveau.com/

[-- Attachment #2: Type: application/pgp-signature, Size: 193 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 13:45   ` Gary
@ 2010-10-01 15:23     ` rasmith
  2010-10-05  6:47       ` Gary
  0 siblings, 1 reply; 12+ messages in thread
From: rasmith @ 2010-10-01 15:23 UTC (permalink / raw)
  To: help-gnu-emacs

From: Gary <help-gnu-emacs@garydjones.name>
Subject: Re: Regex to match "define ABC-123-xyz"
Date: Fri, 01 Oct 2010 15:45:04 +0200

> It now works okay in the RE-Builder for me too, but not in the mode I
> have written. I imagine the REs for different parts of the language are
> getting in the way of each other somewhere. I will try removing some
> until I get something that works and go on from there...
> 

My guess is that there's some problem with escaping special characters
in the context in which you're using it.  As an example of what I
mean, you're probably aware that in query-replace-regexp, you need to
enter "(" and ")"as "\(" and "\)" if they're intended as regexp
subexpression delimiters rather than literal parentheses.  

So, where are you using it?



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
       [not found]   ` <mailman.4.1285942809.2643.help-gnu-emacs@gnu.org>
@ 2010-10-01 16:04     ` rustom
  0 siblings, 0 replies; 12+ messages in thread
From: rustom @ 2010-10-01 16:04 UTC (permalink / raw)
  To: help-gnu-emacs

On Oct 1, 6:59 pm, "Erik L. Arneson" <dyb...@lnouv.com> wrote:
> On Fri, 01 Oct 2010, Tim Visher wrote:
> > Don't really understand what's going on.  I type the following into
> > scratch and use `M-x regex-builder` and it works exactly as I believe
> > you want it to.
>
> I love this group!  I didn't even know about `regexp-builder', and now
> I'm crazy about it.  Thank you.
>
> Holy crap, that function is going to make my life easier.

Thats the %^%*($$@ problem with emacs -- you are always at about 5% of
what you could be doing if only...
(at least thats where I am after 20 years use :-) )

In this particular case you may find John Wiegley's version
http://www.newartisans.com/2007/10/a-regular-expression-ide-for-emacs.html
more useful if for example you want to hack out a perl regexp.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Regex to match "define ABC-123-xyz"
  2010-10-01 15:23     ` rasmith
@ 2010-10-05  6:47       ` Gary
  0 siblings, 0 replies; 12+ messages in thread
From: Gary @ 2010-10-05  6:47 UTC (permalink / raw)
  To: help-gnu-emacs

rasmith@tamu.edu wrote:

>> I imagine the REs for different parts of the language
> are
>> getting in the way of each other somewhere. I will try removing some
>> until I get something that works and go on from there...
>> 
>
> My guess is that there's some problem with escaping special characters
> in the context in which you're using it.

No, it was what I said. Have a look at
http://xahlee.org/emacs/elisp_syntax_coloring.html "the order of your
[font-lock list] list is important. Make sure the smallest lengthed text
goes last."

-- 
Gary        Please do NOT send me 'courtesy' replies off-list.
GNU Emacs 23.2.1
emacsclient 23.2




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-10-05  6:47 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.0.1285935054.30433.help-gnu-emacs@gnu.org>
2010-10-01 12:20 ` Regex to match "define ABC-123-xyz" Marc Mientki
2010-10-01 12:26 ` David Kastrup
2010-10-01 12:10 Gary
2010-10-01 12:18 ` Deniz Dogan
2010-10-01 13:45   ` Gary
2010-10-01 15:23     ` rasmith
2010-10-05  6:47       ` Gary
2010-10-01 12:48 ` Tyler Smith
2010-10-01 13:42   ` Gary
2010-10-01 12:58 ` Tim Visher
2010-10-01 13:59   ` Erik L. Arneson
     [not found]   ` <mailman.4.1285942809.2643.help-gnu-emacs@gnu.org>
2010-10-01 16:04     ` rustom

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.