From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Greg Hill Newsgroups: gmane.emacs.help Subject: Re: RegExp question Date: Thu, 23 Sep 2004 11:05:29 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: <20040923164158.69419.qmail@web51603.mail.yahoo.com> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0869741350==" X-Trace: sea.gmane.org 1095962768 4084 80.91.229.6 (23 Sep 2004 18:06:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 23 Sep 2004 18:06:08 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 23 20:05:58 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CAXyg-000587-00 for ; Thu, 23 Sep 2004 20:05:58 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CAY4i-0003NR-If for geh-help-gnu-emacs@m.gmane.org; Thu, 23 Sep 2004 14:12:12 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CAY4Z-0003NM-B5 for help-gnu-emacs@gnu.org; Thu, 23 Sep 2004 14:12:03 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CAY4V-0003LQ-KQ for help-gnu-emacs@gnu.org; Thu, 23 Sep 2004 14:12:03 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CAY4V-0003LK-HJ for help-gnu-emacs@gnu.org; Thu, 23 Sep 2004 14:11:59 -0400 Original-Received: from [207.158.54.5] (helo=renfield.synergymicro.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.34) id 1CAXyB-0000BF-DB for help-gnu-emacs@gnu.org; Thu, 23 Sep 2004 14:05:27 -0400 Original-Received: from synergy.san.synergymicro.com (synergy.san.synergymicro.com [10.1.2.12]) by renfield.synergymicro.com (8.12.10/8.12.10) with ESMTP id i8NI8I9f012322 for ; Thu, 23 Sep 2004 11:08:18 -0700 Original-Received: from [10.1.5.75] ([10.1.5.75]) by synergy.san.synergymicro.com (8.12.10/8.12.10) with ESMTP id i8NI6QkK031937 for ; Thu, 23 Sep 2004 11:06:26 -0700 In-Reply-To: <20040923164158.69419.qmail@web51603.mail.yahoo.com> Original-To: X-Virus-Scanned: clamd / ClamAV version 0.70, clamav-milter version 0.70j X-CanItPRO-Stream: default X-Canit-Stats-ID: 271659 - 7dbe5fefcb0a X-Scanned-By: CanIt (www . canit . ca) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:20834 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:20834 --===============0869741350== Content-Type: multipart/alternative; boundary="============_-1116159765==_ma============" --============_-1116159765==_ma============ Content-Type: text/plain; charset="us-ascii" ; format="flowed" Ryan, Depending on exactly what you are trying to accomplish, this may or may not do the trick for you. For example, if the word "repeat" is followed by a space character, the space character _will_ be part of the match. But if the word you are searching for is always at the end of a line, this should do what you want. (re-search-forward "repeat\\(-[xy]?\\)?\\([^:\n]+\\|$\\)") If your requirements are more complicated, it may be necessary to write your own function that does more than just a single call to re-search-forward. --Greg At 9:41 AM -0700 9/23/04, Ryan Bowman wrote: >I have a regexp "repeat\\(-[xy]?\\)?" this should >match >repeat >repeat-x >repeat-y >, which it does, however it also matches >background-repeat: >which I don't want it to. >So I changed it to this "repeat\\(-[xy]?\\)?[^:]" >so it won't match background-repeat: but then it no >longer matches repeat, >I assume because [^:] actually means to match >something, but not a ':' >so how do I specifiy that I don't care if anything >follows the patter or not, >so long as it is NOT ':'? --============_-1116159765==_ma============ Content-Type: text/html; charset="us-ascii" Re: RegExp question
Ryan,

Depending on exactly what you are trying to accomplish, this may or may not do the trick for you.  For example, if the word "repeat" is followed by a space character, the space character _will_ be part of the match.  But if the word you are searching for is always at the end of a line, this should do what you want.


(re-search-forward "repeat\\(-[xy]?\\)?\\([^:\n]+\\|$\\)")

If your requirements are more complicated, it may be necessary to write your own function that does more than just a single call to re-search-forward.

--Greg

At 9:41 AM -0700 9/23/04, Ryan Bowman wrote:
I have a regexp "repeat\\(-[xy]?\\)?" this should
match
repeat
repeat-x
repeat-y
, which it does, however it also matches
background-repeat:
which I don't want it to.
So I changed it to this "repeat\\(-[xy]?\\)?[^:]"
so it won't match background-repeat: but then it no
longer matches repeat,
I assume because [^:] actually means to match
something, but not a ':'
so how do I specifiy that I don't care if anything
follows the patter or not,
so long as it is NOT ':'?
--============_-1116159765==_ma============-- --===============0869741350== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Help-gnu-emacs mailing list Help-gnu-emacs@gnu.org http://lists.gnu.org/mailman/listinfo/help-gnu-emacs --===============0869741350==--