all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* efficient regular expression that never matches
@ 2015-11-20  9:35 cinsk
  2015-11-20 15:13 ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: cinsk @ 2015-11-20  9:35 UTC (permalink / raw)
  To: help-gnu-emacs

hi,

Is there any special regular expression string that never matches
anything?

I'm thinking of "$a", but it should scan all the string until end
of the string, so it may not be efficient.

Is there any short, efficient regular expression that never
matches anything? (it's okay with Emacs-specific regular
expression, since I'm going to use it with `directory-files' or
`string-match' function)
 
Thank you.


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

* Re: efficient regular expression that never matches
  2015-11-20  9:35 efficient regular expression that never matches cinsk
@ 2015-11-20 15:13 ` Stefan Monnier
  2015-11-20 15:59   ` John Wiegley
       [not found]   ` <mailman.342.1448035187.31583.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Stefan Monnier @ 2015-11-20 15:13 UTC (permalink / raw)
  To: help-gnu-emacs

> I'm thinking of "$a", but it should scan all the string until end
> of the string, so it may not be efficient.

IIRC I used something like "\\`\\'a".


        Stefan




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

* Re: efficient regular expression that never matches
  2015-11-20 15:13 ` Stefan Monnier
@ 2015-11-20 15:59   ` John Wiegley
       [not found]   ` <mailman.342.1448035187.31583.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: John Wiegley @ 2015-11-20 15:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

>>>>> Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> I'm thinking of "$a", but it should scan all the string until end of the
>> string, so it may not be efficient.

> IIRC I used something like "\\`\\'a".

Yes, also because "$" only has special meaning as the last character of the
regexp, whereas \\' should always mean "end of <context>".

John



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

* Re: efficient regular expression that never matches
       [not found]   ` <mailman.342.1448035187.31583.help-gnu-emacs@gnu.org>
@ 2015-11-21  5:52     ` cinsk
  2015-11-21 15:04       ` Stefan Monnier
  0 siblings, 1 reply; 5+ messages in thread
From: cinsk @ 2015-11-21  5:52 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, November 21, 2015 at 12:59:51 AM UTC+9, John Wiegley wrote:
> >>>>> Stefan Monnier <monnier at iro.umontreal.ca> writes:
> 
> >> I'm thinking of "$a", but it should scan all the string until end of the
> >> string, so it may not be efficient.
> 
> > IIRC I used something like "\\`\\'a".
> 
> Yes, also because "$" only has special meaning as the last character of the
> regexp, whereas \\' should always mean "end of <context>".
> 
> John

Yes, I agree with that,

However, "$a" means that the regular expression engine may read all strings until the end of the line.  So, if I can do something like "^<SOME CHARACTER OR CONDITION IMPOSSIBLE>", then the engine should detect before reading all characters of the line, I presume.  Perhaps "^\uFFFFF" can be a solution?  Since \uFFFF is noncharacter of the unicode (\uFFFF can be use for the internal purpose but generally not used.)


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

* Re: efficient regular expression that never matches
  2015-11-21  5:52     ` cinsk
@ 2015-11-21 15:04       ` Stefan Monnier
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Monnier @ 2015-11-21 15:04 UTC (permalink / raw)
  To: help-gnu-emacs

> until the end of the line.  So, if I can do something like "^<SOME CHARACTER
> OR CONDITION IMPOSSIBLE>", then the engine should detect before reading all
> characters of the line, I presume.  Perhaps "^\uFFFFF" can be a solution?

That's what the \\` is for in my solution.


        Stefan




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

end of thread, other threads:[~2015-11-21 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-20  9:35 efficient regular expression that never matches cinsk
2015-11-20 15:13 ` Stefan Monnier
2015-11-20 15:59   ` John Wiegley
     [not found]   ` <mailman.342.1448035187.31583.help-gnu-emacs@gnu.org>
2015-11-21  5:52     ` cinsk
2015-11-21 15:04       ` Stefan Monnier

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.