* trivial regexp problem
@ 2013-01-22 10:52 Luca Ferrari
2013-01-22 11:00 ` Bastien
0 siblings, 1 reply; 7+ messages in thread
From: Luca Ferrari @ 2013-01-22 10:52 UTC (permalink / raw)
To: help-gnu-emacs
Hi all,
I need a little hint on a regexp that is not working within lookig-at:
I want to recognize any label of the form "label:" so I tested the
following against re-search-forward "^[ \t]*.*:" and it works.
However, the same into a looking-at call is not working, so how can I
find the following regexp?
Thanks,
Luca
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
2013-01-22 10:52 trivial regexp problem Luca Ferrari
@ 2013-01-22 11:00 ` Bastien
2013-01-22 16:27 ` Luca Ferrari
0 siblings, 1 reply; 7+ messages in thread
From: Bastien @ 2013-01-22 11:00 UTC (permalink / raw)
To: Luca Ferrari; +Cc: help-gnu-emacs
Hi Luca,
Luca Ferrari <fluca1978@infinito.it> writes:
> I need a little hint on a regexp that is not working within lookig-at:
> I want to recognize any label of the form "label:" so I tested the
> following against re-search-forward "^[ \t]*.*:" and it works.
> However, the same into a looking-at call is not working, so how can I
> find the following regexp?
It does work for me.
label:
(looking-at "^[ \t]*.*:")
=> t
--
Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
2013-01-22 11:00 ` Bastien
@ 2013-01-22 16:27 ` Luca Ferrari
0 siblings, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-22 16:27 UTC (permalink / raw)
To: Bastien; +Cc: help-gnu-emacs
Sgrunt...I should have tried it into the eshell, There was another
error, not tied to the regexp, that of course is working.
Thanks,
Luca
On Tue, Jan 22, 2013 at 12:00 PM, Bastien <bzg@altern.org> wrote:
> Hi Luca,
>
> Luca Ferrari <fluca1978@infinito.it> writes:
>
>> I need a little hint on a regexp that is not working within lookig-at:
>> I want to recognize any label of the form "label:" so I tested the
>> following against re-search-forward "^[ \t]*.*:" and it works.
>> However, the same into a looking-at call is not working, so how can I
>> find the following regexp?
>
> It does work for me.
>
> label:
>
> (looking-at "^[ \t]*.*:")
> => t
>
> --
> Bastien
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
[not found] <mailman.18061.1358852367.855.help-gnu-emacs@gnu.org>
@ 2013-01-22 16:44 ` Barry Margolin
2013-01-22 17:50 ` Peter Dyballa
[not found] ` <mailman.18090.1358877053.855.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 7+ messages in thread
From: Barry Margolin @ 2013-01-22 16:44 UTC (permalink / raw)
To: help-gnu-emacs
In article <mailman.18061.1358852367.855.help-gnu-emacs@gnu.org>,
Luca Ferrari <fluca1978@infinito.it> wrote:
> Hi all,
> I need a little hint on a regexp that is not working within lookig-at:
> I want to recognize any label of the form "label:" so I tested the
> following against re-search-forward "^[ \t]*.*:" and it works.
> However, the same into a looking-at call is not working, so how can I
> find the following regexp?
What's the purpose of [ \t]* at the beginning of the regexp? Since it's
immediately followed by .*, which matches anything, the regexp will
match whether or not the line begins with whitespace.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
2013-01-22 16:44 ` Barry Margolin
@ 2013-01-22 17:50 ` Peter Dyballa
[not found] ` <mailman.18090.1358877053.855.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 7+ messages in thread
From: Peter Dyballa @ 2013-01-22 17:50 UTC (permalink / raw)
To: Barry Margolin; +Cc: help-gnu-emacs
Am 22.01.2013 um 17:44 schrieb Barry Margolin:
> Since it's
> immediately followed by .*, which matches anything, the regexp will
> match whether or not the line begins with whitespace.
Yes, it not only matches the beginning of every line, it also matches the beginning of every empty line…
--
Greetings
Pete
My sister opened a computer store in Hawaii. She sells C shells down by the seashore.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
[not found] ` <mailman.18090.1358877053.855.help-gnu-emacs@gnu.org>
@ 2013-01-22 20:02 ` Barry Margolin
2013-01-23 7:43 ` Luca Ferrari
0 siblings, 1 reply; 7+ messages in thread
From: Barry Margolin @ 2013-01-22 20:02 UTC (permalink / raw)
To: help-gnu-emacs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 883 bytes --]
In article <mailman.18090.1358877053.855.help-gnu-emacs@gnu.org>,
Peter Dyballa <Peter_Dyballa@Web.DE> wrote:
> Am 22.01.2013 um 17:44 schrieb Barry Margolin:
>
> > Since it's
> > immediately followed by .*, which matches anything, the regexp will
> > match whether or not the line begins with whitespace.
>
> Yes, it not only matches the beginning of every line, it also matches the
> beginning of every empty line
That's not an issue, because the regexp includes ":". So it only matches
on lines that contain a colon.
But there's no difference between:
^[ \t]*.*:
and:
^.*:
There *would* be a difference if you used grouping, e.g.:
^\([ \t]*\)\(.*\):
because this allows you to extract the whitespace prefix and the part of
the line after it.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: trivial regexp problem
2013-01-22 20:02 ` Barry Margolin
@ 2013-01-23 7:43 ` Luca Ferrari
0 siblings, 0 replies; 7+ messages in thread
From: Luca Ferrari @ 2013-01-23 7:43 UTC (permalink / raw)
To: help-gnu-emacs
Correct! Since I'm not interested in separating spaces from other
parts of the string I fixed the regexp to "^[ \t]*\\(.+\\):[ \t\n]*"
(at least one letter before the colon must be present).
Thanks guys!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-01-23 7:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 10:52 trivial regexp problem Luca Ferrari
2013-01-22 11:00 ` Bastien
2013-01-22 16:27 ` Luca Ferrari
[not found] <mailman.18061.1358852367.855.help-gnu-emacs@gnu.org>
2013-01-22 16:44 ` Barry Margolin
2013-01-22 17:50 ` Peter Dyballa
[not found] ` <mailman.18090.1358877053.855.help-gnu-emacs@gnu.org>
2013-01-22 20:02 ` Barry Margolin
2013-01-23 7:43 ` Luca Ferrari
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).