all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* string-match: \`  and \= do not match when START is non-zero
@ 2003-04-24 17:37 Kevin Rodgers
  2003-04-26  2:31 ` Richard Stallman
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2003-04-24 17:37 UTC (permalink / raw)


\` or \= should match the empty string at index START in STRING.

(string-match "\\`bar\\'" "foobar" 3) and (string-match "\\=bar\\'" "foobar" 3)
return nil.  I think at least one of them should succeed and return 3, just like
(string-match "bar\\'" "foobar" 3) does.  Otherwise, how can you anchor the
REGEXP at index START in STRING?

[time passes]

(equal (string-match REGEXP STRING START) START)

[never mind]
-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

* Re: string-match: \`  and \= do not match when START is non-zero
  2003-04-24 17:37 string-match: \` and \= do not match when START is non-zero Kevin Rodgers
@ 2003-04-26  2:31 ` Richard Stallman
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2003-04-26  2:31 UTC (permalink / raw)
  Cc: emacs-devel

    \` or \= should match the empty string at index START in STRING.


\' certainly should only match at the beginning of the string,
just as it only matches at the beginning of the buffer.

For \= I am not sure.  I am not sure whether the START value in
string-match is really analogous to point in a buffer.  On the other hand,
currently \= is meaningless in a string, and it might do no harm to
give it this meaning.

I won't try to implement it myself.

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

* Re: string-match: \`  and \= do not match when START is non-zero
       [not found] <mailman.5160.1051205842.21513.bug-gnu-emacs@gnu.org>
@ 2003-04-29 23:54 ` Kevin Rodgers
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Rodgers @ 2003-04-29 23:54 UTC (permalink / raw)


I wrote:

> \` or \= should match the empty string at index START in STRING.
> 
> (string-match "\\`bar\\'" "foobar" 3) and (string-match "\\=bar\\'" 
> "foobar" 3)
> return nil.  I think at least one of them should succeed and return 3, 
> just like
> (string-match "bar\\'" "foobar" 3) does.  Otherwise, how can you anchor the
> REGEXP at index START in STRING?
> 
> [time passes]
> 
> (equal (string-match REGEXP STRING START) START)
> 
> [never mind]

Since START can be negative, that should be:

(equal (string-match REGEXP STRING START)
        (if (minusp START)
	   (+ (length STRING) START)
	 START))

I'm studying regex.c to see if I can implement \= matching in strings...

-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

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

end of thread, other threads:[~2003-04-29 23:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-24 17:37 string-match: \` and \= do not match when START is non-zero Kevin Rodgers
2003-04-26  2:31 ` Richard Stallman
     [not found] <mailman.5160.1051205842.21513.bug-gnu-emacs@gnu.org>
2003-04-29 23:54 ` Kevin Rodgers

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.