From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Rivka Miller Newsgroups: gmane.emacs.help Subject: Re: Quickie - Regexp for a string not at the beginning of the line Date: Thu, 25 Oct 2012 21:45:05 -0700 (PDT) Message-ID: References: <9eba5652-f814-41fa-83e4-460bca2be264@n16g2000yqi.googlegroups.com> <73f60cf3-d932-4366-a405-6767488560c6@q16g2000yqc.googlegroups.com> <0.485c579271f72431d3a7.20121026031110BST.87k3ue7zk1.fsf@bsb.me.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1351226712 2462 80.91.229.3 (26 Oct 2012 04:45:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Oct 2012 04:45:12 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 26 06:45:20 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TRbnM-00053j-Gj for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Oct 2012 06:45:20 +0200 Original-Received: from localhost ([::1]:51671 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TRbnE-0008Nt-F4 for geh-help-gnu-emacs@m.gmane.org; Fri, 26 Oct 2012 00:45:12 -0400 Original-Received: by 10.224.138.142 with SMTP id a14mr11090137qau.4.1351226705206; Thu, 25 Oct 2012 21:45:05 -0700 (PDT) Original-Received: by 10.236.116.67 with SMTP id f43mr1758170yhh.13.1351226705122; Thu, 25 Oct 2012 21:45:05 -0700 (PDT) Original-Path: usenet.stanford.edu!x14no8576551qar.0!news-out.google.com!r17ni69121101qap.0!nntp.google.com!x14no8576547qar.0!postnews.google.com!r6g2000yqd.googlegroups.com!not-for-mail Original-Newsgroups: comp.unix.shell, comp.lang.javascript, comp.lang.python, gnu.emacs.help, comp.emacs Complaints-To: groups-abuse@google.com Injection-Info: r6g2000yqd.googlegroups.com; posting-host=99.42.77.183; posting-account=V5Tx-QoAAACNTDxOswIwdOklJAUE-vym Original-NNTP-Posting-Host: 99.42.77.183 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0,gzip(gfe) Injection-Date: Fri, 26 Oct 2012 04:45:05 +0000 Original-Xref: usenet.stanford.edu comp.unix.shell:256068 comp.lang.javascript:631044 comp.lang.python:686483 gnu.emacs.help:195105 comp.emacs:102661 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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 Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:87434 Archived-At: Thanks everyone, esp this gentleman. The solution that worked best for me is just to use a DOT before the string as the one at the beginning of the line did not have any char before it. I guess, this requires the ability to ignore the CARAT as the beginning of the line. I am a satisfied custormer. No need for returns. :) On Oct 25, 7:11=A0pm, Ben Bacarisse wrote: > Rivka Miller writes: > > On Oct 25, 2:27=A0pm, Danny wrote: > >> Why you just don't give us the string/input, say a line or two, and > >> what you want off of it, so we can tell better what to suggest > > > no one has really helped yet. > > Really? =A0I was going to reply but then I saw Janis had given you the > answer. =A0If it's not the answer, you should just reply saying what it i= s > that's wrong with it. > > > I want to search and modify. > > Ah. =A0That was missing from the original post. =A0You can't expect peopl= e > to help with questions that weren't asked! =A0To replace you will usually > have to capture the single preceding character. =A0E.g. in sed: > > =A0 sed -e 's/\(.\)$hello\$/\1XXX/' > > but some RE engines (Perl's, for example) allow you specify zero-width > assertions. =A0You could, in Perl, write > > =A0 s/(?<=3D.)\$hello\$/XXX/ > > without having to capture whatever preceded the target string. =A0But > since Perl also has negative zero-width look-behind you can code your > request even more directly: > > =A0 s/(? > > I dont wanna be tied to a specific language etc so I just want a > > regexp and as many versions as possible. Maybe I should try in emacs > > and so I am now posting to emacs groups also, although javascript has > > rich set of regexp facilities. > > You can't always have a universal solution because different PE > implementations have different syntax and semantics, but you should be > able to translate Janis's solution of matching *something* before your > target into every RE implementation around. > > > examples > > > $hello$ should not be selected but > > not hello but all of the $hello$ and $hello$ ... $hello$ each one > > selected > > I have taken your $s to be literal. =A0That's not 100 obvious since $ is = a > common (universal?) RE meta-character. > > > -- > Ben.