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

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

Re: How to check regexp for syntax-errors? (There HAS to be SOME way, y


From: tomas
Subject: Re: How to check regexp for syntax-errors? (There HAS to be SOME way, yes?)
Date: Sat, 17 Oct 2009 08:01:38 +0200
User-agent: Mutt/1.5.15+20070412 (2007-04-11)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Oct 16, 2009 at 01:19:04PM -0400, David Combs wrote:
> Trying to get this to work:

[...]

As Andreas already noted, your (primary) problem here isn't with the
regexp. There just isn't a function named "Occur". I guess it's "occur"
you are after:

> (Occur 
> "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")
>      ,
> 
> But here's what I get back:
> 
> 
> Debugger entered--Lisp error: (void-function Occur)
                this is the clue ^^^^^^^^^^^^^^^^^^^
>   (Occur 
> "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")
>   eval((Occur 
> "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3"))
>   eval-expression((Occur 
> "\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3")
>  nil)
>   call-interactively(eval-expression)
>   recursive-edit()
>   byte-code("        @ = !
> 
> 
> Which is completely "Greek" to me!

Understandable :-)

Emacs tries to be helpful showing you the "call stack", i.e. from where
the statement was called which gave it hiccups.

As to the regexp...

   
"\\([0-9][0-9]\\)\\([0-9][0-9]\\)\\([0-9][0-9]\\)_\\([0-9][0-9][0-9][0-9][0-9][0-9]\\)1\\([a-zA-Z\\][0-9a-zA-Z]*\\).mp3"

it is syntaactically fine as it is, but won't match your data:

      -rw-rw-rw-   1 David    root      10895733 10-16 09:51 
091005_100001pilotmon.MP3

at least for several reasons:

  - the ".mp3" at the end is lowercase in the regexp, upercase in your
    data.
  - this long string of [0-9] with which you are trying to match the
    100001 in the example above _already_ matches all six digits -- thus
    the "1" after the parenthesis in the regexp turns out empty-handed.
  - I don't know whether the construct near the end:

          [a-zA-Z\\][0-9a-zA-Z]*

    is really doing what you think it should (it looks to me a bit like
    you wanted to say:

          [a-zA-Z][0-9a-zA-Z]*

    i.e. "one character and zero or more characters or digits")

> Isn't there some .el that that will try to parse a regexp, and tell
> me where it got confused, and what to look for for errors?

Others have answered this question in the thread.

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFK2V3CBcgs9XrR2kYRAmmoAJ0cvr24IBhvCzguoaA/9+WUKF8J2wCfcSXx
dtll6FwQmTTwWEP5IWul5VQ=
=uRL7
-----END PGP SIGNATURE-----




reply via email to

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