Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
does emacs regular expression support (?!expression)
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
土星五号  
View profile  
 More options Feb 2 2012, 9:02 am
Newsgroups: gnu.emacs.help
From: 土星五号 <laf...@gmail.com>
Date: Thu, 2 Feb 2012 22:02:08 +0800
Local: Thurs, Feb 2 2012 9:02 am
Subject: does emacs regular expression support (?!expression)

does emacs regular expression support (?!expression)  ?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Feb 2 2012, 1:56 pm
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Thu, 02 Feb 2012 19:56:51 +0100
Local: Thurs, Feb 2 2012 1:56 pm
Subject: Re: does emacs regular expression support (?!expression)

土星五号 <laf...@gmail.com> writes:
> does emacs regular expression support (?!expression) ?

It would be more helpful if you'd tell us what (?!expression) would
match, preferably with some examples.  Syntactically, emacs regexp's shy
groups look similar.  The regular expression

  "\\(:?foo\\|bar\\)\\([0-9]+\\)"

matches "foo19" or "bar23", but doesn't capture foo or bar, so that
(match-string 1) is the number.

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 2 2012, 4:14 pm
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Thu, 02 Feb 2012 21:14:40 +0000
Local: Thurs, Feb 2 2012 4:14 pm
Subject: Re: does emacs regular expression support (?!expression)

Tassilo Horn <tass...@member.fsf.org> wrote:
>> does emacs regular expression support (?!expression) ?
> It would be more helpful if you'd tell us what (?!expression) would
> match, preferably with some examples.  Syntactically, emacs regexp's shy
> groups look similar.  The regular expression
>   "\\(:?foo\\|bar\\)\\([0-9]+\\)"
> matches "foo19" or "bar23", but doesn't capture foo or bar, so that
> (match-string 1) is the number.

In Perl, "(?!pattern)" is a zero-width negative look-ahead
assertion.  Emacs does not support these AFAIK.

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tassilo Horn  
View profile  
 More options Feb 2 2012, 4:45 pm
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Thu, 02 Feb 2012 22:45:04 +0100
Local: Thurs, Feb 2 2012 4:45 pm
Subject: Re: does emacs regular expression support (?!expression)

Tim Landscheidt <t...@tim-landscheidt.de> writes:

Hi Tim,

>> It would be more helpful if you'd tell us what (?!expression) would
>> match, preferably with some examples.  Syntactically, emacs regexp's shy
>> groups look similar.  The regular expression

>>   "\\(:?foo\\|bar\\)\\([0-9]+\\)"

BTW, that should have been (?:...).

>> matches "foo19" or "bar23", but doesn't capture foo or bar, so that
>> (match-string 1) is the number.

> In Perl, "(?!pattern)" is a zero-width negative look-ahead
> assertion.  Emacs does not support these AFAIK.

I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
"foo\\(?:[^b][^a][^r]\\)" in elisp.

Bye,
Tassilo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Glenn Morris  
View profile  
 More options Feb 2 2012, 5:09 pm
Newsgroups: gnu.emacs.help
From: Glenn Morris <r...@gnu.org>
Date: Thu, 02 Feb 2012 17:09:43 -0500
Local: Thurs, Feb 2 2012 5:09 pm
Subject: Re: does emacs regular expression support (?!expression)

Tim Landscheidt wrote:
> In Perl, "(?!pattern)" is a zero-width negative look-ahead
> assertion.  Emacs does not support these AFAIK.

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=5393
(to date, not applied)

See also the linked
http://lists.gnu.org/archive/html/emacs-devel/2012-01/msg00732.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 2 2012, 5:11 pm
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Thu, 02 Feb 2012 22:11:27 +0000
Local: Thurs, Feb 2 2012 5:11 pm
Subject: Re: does emacs regular expression support (?!expression)

Tassilo Horn <tass...@member.fsf.org> wrote:
> [...]
>>> matches "foo19" or "bar23", but doesn't capture foo or bar, so that
>>> (match-string 1) is the number.
>> In Perl, "(?!pattern)" is a zero-width negative look-ahead
>> assertion.  Emacs does not support these AFAIK.
> I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
> "foo\\(?:[^b][^a][^r]\\)" in elisp.

You have to account for possible end-of-buffer as well so
usually it's "easier" to use two matches ('(while (and
(search-forward-regexp "foo") (not (looking-at "bar"))))'
(untested)) - that's why I (still :-)) think these features
should be implemented in Emacs as well.

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 2 2012, 5:17 pm
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Thu, 02 Feb 2012 22:17:04 +0000
Local: Thurs, Feb 2 2012 5:17 pm
Subject: Re: does emacs regular expression support (?!expression)

I wrote:
>> [...]
>>>> matches "foo19" or "bar23", but doesn't capture foo or bar, so that
>>>> (match-string 1) is the number.
>>> In Perl, "(?!pattern)" is a zero-width negative look-ahead
>>> assertion.  Emacs does not support these AFAIK.
>> I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
>> "foo\\(?:[^b][^a][^r]\\)" in elisp.
> You have to account for possible end-of-buffer as well so
> usually it's "easier" to use two matches ('(while (and
> (search-forward-regexp "foo") (not (looking-at "bar"))))'
> (untested)) - [...]

Eh, yes, there is an "(untested)", but still the logic is
obviously plain wrong.  But you get the idea.

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kevin Rodgers  
View profile  
 More options Feb 2 2012, 7:37 pm
Newsgroups: gnu.emacs.help
From: Kevin Rodgers <kevin.d.rodg...@gmail.com>
Date: Thu, 02 Feb 2012 17:37:57 -0700
Local: Thurs, Feb 2 2012 7:37 pm
Subject: Re: does emacs regular expression support (?!expression)
On 2/2/12 2:45 PM, Tassilo Horn wrote:

> Tim Landscheidt<t...@tim-landscheidt.de>  writes:
>> In Perl, "(?!pattern)" is a zero-width negative look-ahead
>> assertion.  Emacs does not support these AFAIK.

> I see.  So when you do /foo(?!bar)/ in Perl, you'd need to do
> "foo\\(?:[^b][^a][^r]\\)" in elisp.

IIUC, the Perl regex would successfully match "foo" if it were followed by
"far", but the Emacs regexp would not.

Maybe \(?:[^b][^a][^r]\) should be \(?:[^b]\|b[^a]\|ba[^r]\)

--
Kevin Rodgers
Denver, Colorado, USA


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
土星五号  
View profile  
 More options Feb 2 2012, 9:12 pm
Newsgroups: gnu.emacs.help
From: 土星五号 <laf...@gmail.com>
Date: Fri, 3 Feb 2012 10:12:27 +0800
Local: Thurs, Feb 2 2012 9:12 pm
Subject: Re: does emacs regular expression support (?!expression)

I would like match Err in any words(e.g. LastError), but not ErrorMode.
(defvar txt-mode-font-lock-keywords
  `(
    ;; 文件名
    ("\\\\\\(\\w+\\.exe\\)" 1 font-lock-keyword-face)
    ;; IP和版本

("[^0-9]\\([0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\}\\.[0-9]\\{1,3\\ }\\)"
1 font-lock-keyword-face)
    ;; Error
    ("\\<\\([Dd][Bb][Ee][Rr][Rr][Oo][Rr]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Dd][Bb][Ee][Rr][Rr]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Ee][Rr][Rr][Oo][Rr]\\)\\>" 1 font-lock-warning-face)
    ("\\([Ee][Rr][Rr]\\)\\(?!orMode\\)" 1 font-lock-warning-face)
    ("\\(错误\\)" 1 font-lock-warning-face)
    ("\\(失败\\)" 1 font-lock-warning-face)
    ("\\(严重\\)" 1 font-lock-warning-face)
    ("\\<\\([Ff][Aa][Ii][Ll][Ee][Dd]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Ff][Aa][Ii][Ll]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Cc][Aa][Nn]\\s+[Nn][Oo][Tt]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Cc][Aa][Nn]'[Tt]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Ww][Rr][Oo][Nn][Gg]\\)\\>" 1 font-lock-warning-face)
    ;; Warning
    ("\\<\\([Ww][Aa][Rr][Nn][Ii][Nn][Gg]\\)\\>" 1 font-lock-warning-face)
    ("\\<\\([Ww][Aa][Rr][Nn]\\)\\>" 1 font-lock-warning-face)
    ("\\(警告\\)" 1 font-lock-warning-face)
    ;; Exception
    ("\\<\\([Ee][Xx][Cc][Ee][Pp][Tt][Ii][Oo][Nn]\\)\\>" 1
font-lock-warning-face)
    ("\\<\\([Ee][Xx][Cc][Ee][Pp][Tt]\\)\\>" 1 font-lock-warning-face)
    ("\\(异常\\)" 1 font-lock-warning-face)
    )
  "Basic font lock keywords for txt mode.  Highlights keywords.")

2012/2/3 Kevin Rodgers <kevin.d.rodg...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thien-Thi Nguyen  
View profile  
 More options Feb 3 2012, 3:30 am
Newsgroups: gnu.emacs.help
From: Thien-Thi Nguyen <t...@gnuvola.org>
Date: Fri, 03 Feb 2012 09:30:42 +0100
Local: Fri, Feb 3 2012 3:30 am
Subject: Re: does emacs regular expression support (?!expression)
() 土星五号 <laf...@gmail.com>
() Fri, 3 Feb 2012 10:12:27 +0800

   I would like match Err in any words(e.g. LastError), but not ErrorMode.

       ("\\([Ee][Rr][Rr]\\)\\(?!orMode\\)" 1 font-lock-warning-face)

You can add a spec for ‘ErrorMode’, with default face, prior to this one.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 3 2012, 6:17 am
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Fri, 03 Feb 2012 11:17:25 +0000
Local: Fri, Feb 3 2012 6:17 am
Subject: Re: does emacs regular expression support (?!expression)

Thien-Thi Nguyen <t...@gnuvola.org> wrote:
>    I would like match Err in any words(e.g. LastError), but not ErrorMode.
>        ("\\([Ee][Rr][Rr]\\)\\(?!orMode\\)" 1 font-lock-warning-face)
> You can add a spec for ‘ErrorMode’, with default face, prior to this one.

Which Emacs version does support that?

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Thien-Thi Nguyen  
View profile  
 More options Feb 3 2012, 6:48 am
Newsgroups: gnu.emacs.help
From: Thien-Thi Nguyen <t...@gnuvola.org>
Date: Fri, 03 Feb 2012 12:48:11 +0100
Local: Fri, Feb 3 2012 6:48 am
Subject: Re: does emacs regular expression support (?!expression)
() Tim Landscheidt <t...@tim-landscheidt.de>
() Fri, 03 Feb 2012 11:17:25 +0000

   > You can add a spec for ‘ErrorMode’, with default face, prior to this one.

   Which Emacs version does support that?

Any that processes these specs in the given order, with
"masking semantics", i suppose.  (I haven't tried.)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 4 2012, 5:12 am
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Sat, 04 Feb 2012 10:12:33 +0000
Local: Sat, Feb 4 2012 5:12 am
Subject: Re: does emacs regular expression support (?!expression)

Thien-Thi Nguyen <t...@gnuvola.org> wrote:
>    > You can add a spec for ‘ErrorMode’, with default face, prior to this one.
>    Which Emacs version does support that?
> Any that processes these specs in the given order, with
> "masking semantics", i suppose.  (I haven't tried.)

What does:

| (search-forward-regexp "\\([Ee][Rr][Rr]\\)\\(?!orMode\\)")

give on your Emacs?

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
土星五号  
View profile  
 More options Feb 4 2012, 7:16 am
Newsgroups: gnu.emacs.help
From: 土星五号 <laf...@gmail.com>
Date: Sat, 4 Feb 2012 20:16:29 +0800
Local: Sat, Feb 4 2012 7:16 am
Subject: Re: does emacs regular expression support (?!expression)

No, i put it in txt-mode-load.el.

 .emacs:
(require 'txt-mode-load)

2012/2/4 Tim Landscheidt <t...@tim-landscheidt.de>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tim Landscheidt  
View profile  
 More options Feb 5 2012, 6:57 am
Newsgroups: gnu.emacs.help
From: Tim Landscheidt <t...@tim-landscheidt.de>
Date: Sun, 05 Feb 2012 11:57:41 +0000
Local: Sun, Feb 5 2012 6:57 am
Subject: Re: does emacs regular expression support (?!expression)

Thien-Thi Nguyen <t...@gnuvola.org> wrote:
> [...]
> It throws an error "Invalid regular expression".
> Sorry for being unclear.  [...]

Thanks.

Tim


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Combs  
View profile  
 More options Mar 10 2012, 8:53 pm
Newsgroups: gnu.emacs.help
From: dkco...@panix.com (David Combs)
Date: Sun, 11 Mar 2012 01:53:01 +0000 (UTC)
Local: Sat, Mar 10 2012 8:53 pm
Subject: Re: does emacs regular expression support (?!expression)
In article <mailman.3005.1328220706.15002.help-gnu-em...@gnu.org>,
Tim Landscheidt  <t...@tim-landscheidt.de> wrote:

And, by the above, that's not a "regexp" (emacs), but a bunch of
elisp code.  Meaning that (as far as I know) you can't just
type it in, in response to a prompt-for-a-regexp, as you'd get
with a M-C s, query-replace-regexp, etc, but would have to --
well, what *would* you have to do for a M-C % -- you would have
to write a whole paragraph of elisp to duplicate what query-replace-regexp
does, somewhere inserting the above elisp that emulates the perl
regexp?

Easier to just get out of emacs for a bit, and do that perl-like
edit in perl itself?

David


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »