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
regexp-builder shows matches, re-search-forward fails?
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
  12 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
 
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 6:51 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 12:51:36 +0200
Local: Thurs, Jul 26 2012 6:51 am
Subject: regexp-builder shows matches, re-search-forward fails?

Hi List,

I constructed a regexp with regexp-builder for a buffer, the matches are
clearly shown, with all the subexpressions in different colors. Then I
do reb-copy and paste the regexp as argument for a re-search-forward
call. In the same buffer I used to build the regexp, re-search-forward
now fails to match anything.

What might be the reason?

--
cheers,
Thorsten


 
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.
Jambunathan K  
View profile  
 More options Jul 26 2012, 6:54 am
Newsgroups: gnu.emacs.help
From: Jambunathan K <kjambunat...@gmail.com>
Date: Thu, 26 Jul 2012 16:24:49 +0530
Local: Thurs, Jul 26 2012 6:54 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:
> Hi List,

> I constructed a regexp with regexp-builder for a buffer, the matches are
> clearly shown, with all the subexpressions in different colors. Then I
> do reb-copy and paste the regexp as argument for a re-search-forward
> call. In the same buffer I used to build the regexp, re-search-forward
> now fails to match anything.

> What might be the reason?

Check you `point'.  Is it already past the matches?

--


 
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.
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 7:15 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 13:15:32 +0200
Local: Thurs, Jul 26 2012 7:15 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Jambunathan K <kjambunat...@gmail.com> writes:
> Check you `point'.  Is it already past the matches?

No, I use (goto-char (point-min)) before the re-search-forward. And I
print out the (current-buffer in the function - its the right one).

BTW its a temp buffer - but that shouldn't matter, right?

--
cheers,
Thorsten


 
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 Jul 26 2012, 7:17 am
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Thu, 26 Jul 2012 13:17:13 +0200
Local: Thurs, Jul 26 2012 7:17 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:

Hi Thorsten,

> I constructed a regexp with regexp-builder for a buffer, the matches
> are clearly shown, with all the subexpressions in different colors.
> Then I do reb-copy and paste the regexp as argument for a
> re-search-forward call.  In the same buffer I used to build the
> regexp, re-search-forward now fails to match anything.

> What might be the reason?

What's reb-copy?

The problem might be that re-builder wants the regex as string, so you
have to quote backslashes.  E.g., re-builder wants "\\(foo\\|bar\\)",
but at the re-search-forward prompt you have to say just \(foo\|bar\)
and emacs does the quoting for you.

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.
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 7:23 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 13:23:37 +0200
Local: Thurs, Jul 26 2012 7:23 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:
> Jambunathan K <kjambunat...@gmail.com> writes:

>> Check you `point'.  Is it already past the matches?

> No, I use (goto-char (point-min)) before the re-search-forward. And I
> print out the (current-buffer in the function - its the right one).

> BTW its a temp buffer - but that shouldn't matter, right?

More concrete:

,-------------------------
| \\(^# Task: \\)\\(.*$\\)
`-------------------------

does match both tasks in

,----------------------
| # Task: A+B
|
| (+ (read) (read))
| 3 4
| -> 7
|
|
| # Task: Abstract type
`----------------------

in regexp-builder, but

,------------------------------------------------
| (re-search-forward  "\\(^# Task: \\)\\(.*$\\)")
`------------------------------------------------

with point at beginning of that buffer gives 'search-failed'.

Thats strange.
(I tried \( and \\\\( for escaping too, but to no avail)

--
cheers,
Thorsten


 
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.
Jambunathan K  
View profile  
 More options Jul 26 2012, 7:25 am
Newsgroups: gnu.emacs.help
From: Jambunathan K <kjambunat...@gmail.com>
Date: Thu, 26 Jul 2012 16:55:19 +0530
Local: Thurs, Jul 26 2012 7:25 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:
> Jambunathan K <kjambunat...@gmail.com> writes:

>> Check you `point'.  Is it already past the matches?

> No, I use (goto-char (point-min)) before the re-search-forward. And I
> print out the (current-buffer in the function - its the right one).

> BTW its a temp buffer - but that shouldn't matter, right?

What is your value of `reb-re-syntax'.  Is it in read format?

--


 
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.
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 7:29 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 13:29:30 +0200
Local: Thurs, Jul 26 2012 7:29 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Tassilo Horn <tass...@member.fsf.org> writes:
> Thorsten Jolitz <tjol...@googlemail.com> writes:

Hi Tassilo,

>> I constructed a regexp with regexp-builder for a buffer, the matches
>> are clearly shown, with all the subexpressions in different colors.
>> Then I do reb-copy and paste the regexp as argument for a
>> re-search-forward call.  In the same buffer I used to build the
>> regexp, re-search-forward now fails to match anything.

>> What might be the reason?

> What's reb-copy?

it copies the regexp from regexp-builder for use in an elisp function,
thats what I need.

> The problem might be that re-builder wants the regex as string, so you
> have to quote backslashes.  E.g., re-builder wants "\\(foo\\|bar\\)",
> but at the re-search-forward prompt you have to say just \(foo\|bar\)
> and emacs does the quoting for you.

Thats true, when I use \(foo\|bar\) in M-x re-search-forward it matches
again. But in my function, neither \( nor \\( nor \\\\( work. Maybe
something else wrong with with function - have to check again. Thanks.

--
cheers,
Thorsten


 
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.
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 7:35 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 13:35:58 +0200
Local: Thurs, Jul 26 2012 7:35 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Jambunathan K <kjambunat...@gmail.com> writes:
> What is your value of `reb-re-syntax'.  Is it in read format?

yes.

But I think I got confused, because I used re-search-forward in a while
loop and tried to replace the matches, but the REPLACEMENT didn't work,
the search did - the message "search-failed" was only from the last
iteration in the while loop when no matches were left.

Ok, I got it - thanks for the help and sorry for the noise.

--
cheers,
Thorsten


 
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.
Eric Abrahamsen  
View profile  
 More options Jul 26 2012, 7:36 am
Newsgroups: gnu.emacs.help
From: Eric Abrahamsen <e...@ericabrahamsen.net>
Date: Thu, 26 Jul 2012 19:36:14 +0800
Local: Thurs, Jul 26 2012 7:36 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

On Thu, Jul 26 2012, Thorsten Jolitz wrote:
> Jambunathan K <kjambunat...@gmail.com> writes:

>> What is your value of `reb-re-syntax'.  Is it in read format?

> yes.

> But I think I got confused, because I used re-search-forward in a while
> loop and tried to replace the matches, but the REPLACEMENT didn't work,
> the search did - the message "search-failed" was only from the last
> iteration in the while loop when no matches were left.

Just a note, the second optional argument to re-search-forward is
NOERROR: set to 't', it will allow the search to halt quietly. I kind of
wish that was the default.

--
GNU Emacs 24.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.24.11)
 of 2012-07-23 on pellet


 
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 Jul 26 2012, 9:24 am
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Thu, 26 Jul 2012 15:24:56 +0200
Local: Thurs, Jul 26 2012 9:24 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:
>> What's reb-copy?

> it copies the regexp from regexp-builder for use in an elisp function,
> thats what I need.

Ah, I didn't know that.  And you are using re-search-forward in a
program, not interactively.  Well, in that case, the regex syntax are
identically, i.e., you can kill the "<regex>" from the re-builder prompt
and yank it into (re-search-forward "<regex>" nil t) and it should just
work.

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.
Tassilo Horn  
View profile  
 More options Jul 26 2012, 9:29 am
Newsgroups: gnu.emacs.help
From: Tassilo Horn <tass...@member.fsf.org>
Date: Thu, 26 Jul 2012 15:29:40 +0200
Local: Thurs, Jul 26 2012 9:29 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Thorsten Jolitz <tjol...@googlemail.com> writes:

Hi Thorsten,

Ditto here.

> but

> ,------------------------------------------------
> | (re-search-forward  "\\(^# Task: \\)\\(.*$\\)")
> `------------------------------------------------

> with point at beginning of that buffer gives 'search-failed'.

Not for me.  I can call exactly that twice and point moves to the end of
the # Task items as it should.  The third call then signal no match,
cause there are no more matches.

I used M-: to test that.  Maybe you're running the search on the wrong
buffer?

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.
Thorsten Jolitz  
View profile  
 More options Jul 26 2012, 11:51 am
Newsgroups: gnu.emacs.help
From: Thorsten Jolitz <tjol...@googlemail.com>
Date: Thu, 26 Jul 2012 17:51:04 +0200
Local: Thurs, Jul 26 2012 11:51 am
Subject: Re: regexp-builder shows matches, re-search-forward fails?

Tassilo Horn <tass...@member.fsf.org> writes:

Hi Tassilo,

> Not for me.  I can call exactly that twice and point moves to the end of
> the # Task items as it should.  The third call then signal no match,
> cause there are no more matches.

I figured that out, the search was actually ok, but I made a mistake in
the replacement. Since the whole thing was in a while loop, all
appereances were found, but nothing happened (buggy replacement) and the
last loop gave the error message 'search-failed', so all I saw was that
nothing happened - and that error message, confusing me about the cause
of the error.

--
cheers,
Thorsten


 
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 »