From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: help with pattern-matching Date: Thu, 29 Jan 2015 22:00:46 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8fb1e9eca18514050dd5cf83 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43229) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH1pB-0001r5-SA for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 22:00:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YH1pA-0000tz-A5 for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 22:00:49 -0500 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]:41820) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YH1p9-0000tt-TY for emacs-orgmode@gnu.org; Thu, 29 Jan 2015 22:00:48 -0500 Received: by mail-pa0-f51.google.com with SMTP id fb1so46647801pad.10 for ; Thu, 29 Jan 2015 19:00:46 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Matt Price Cc: Org Mode --e89a8fb1e9eca18514050dd5cf83 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I don't know if this is robust enough for you. the gist is identify some text with a regular expression, and replace that text with something else. I use re-builder to help create the regexps. #+BEGIN_SRC emacs-lisp (let ((s "
Broder, John M., and Ian Urbina. =E2= =80=9CAll Eyes Turn to Virginia Senate Race.=E2=80=9D The New York Times, Nove= mber 9, 2006, sec. /. http://hostname/url.
")) (setq s (replace-regexp-in-string "\\(\.\\)\"" "" s nil nil 1)) (setq s (replace-regexp-in-string "\\(\.\\)" "" s nil nil 1))) #+END_SRC #+RESULTS: :
Broder, John M., and Ian Urbina. =E2=80=9CAll Eyes = Turn to Virginia Senate Race.=E2=80=9D The New York Times, November 9, 2006,= sec. /. http://hostname/url
John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Thu, Jan 29, 2015 at 9:36 PM, Matt Price wrote: > I'm sorry to come with a basic elisp question, once again. > > I continue to work on this citation stuff. Currently, I can get html bac= k > from Zotero in a form like this: > > ----------------- >
Broder, John M., and Ian Urbina. =E2=80=9CAll = Eyes Turn > to Virginia Senate Race.=E2=80=9D The New York Times, November 9, = 2006, sec. > /. http://hostname/url.
> ----------------- > > Note the final "." in the href -- this is a bug in the citeproc-js > citation engine (I think). > > So, I would like to do some postprocessing and just remove the final ".". > But it's not obvious to me how to do that. I feel like it should be! An= d > that for an editor, emacs makes it awfully hard to match patterns & edit > strings. But I think that's partly because I simply understand lisp so > poorly. > > If someone could show me how to do this, nad somehow along hte way make m= e > understand hte basic principles involved so I can start to teach myself > better... well, I would appreciate it. > > thanks again, > Matt > --e89a8fb1e9eca18514050dd5cf83 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I don't know if this is robust enough for you. the gis= t is identify some text with a regular expression, and replace that text wi= th something else. I use re-builder to help create the regexps.

#+BEGIN_SRC emacs-lisp
(let ((s " <div class=3D\"csl-e= ntry\">Broder, John M., and Ian Urbina. =E2=80=9CAll Eyes Turn to V= irginia Senate Race.=E2=80=9D <i>The New York Times</i>, Novemb= er 9, 2006, sec. /. <a href=3D\"http:hostname/url.\">http://hostname/url.</a></div>&qu= ot;))=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0
=C2=A0 (setq s=C2=A0 (replace-regexp-in-string "\\(\.\\)\""= ; "" s nil nil 1))
=C2=A0 (setq s=C2=A0 (replace-regexp-in-str= ing "\\(\.\\)</a>" "" s nil nil 1)))
#+END_SRC=
#+RESULTS:
:=C2=A0 <div class"csl-entr">Broder, John= M., and Ian Urbina. =E2=80=9CAll Eyes Turn to Virginia Senate Race.=E2=80= =9D <i>The New York Times</i>, November 9, 2006, sec. /. <a = href"http:hostname/url">http:/= /hostname/url</a></div>





=

John

------------------= -----------------
Professor John Kitchin=C2=A0
Doherty Hall A207F
= Department of Chemical Engineering
Carnegie Mellon University
Pittsbu= rgh, PA 15213
412-268-7803

On Thu, Jan 29, 2015 at 9:36 PM, Matt Price = <moptop99@gmail.com> wrote:
I'm sorry to come wit= h a basic elisp question, once again.=C2=A0

I continue = to work on this citation stuff.=C2=A0 Currently, I can get html back from Z= otero in a form like this:

-----------------
=C2=A0 <div class= =3D"csl-entry">Broder, John M., and Ian Urbina. =E2=80=9CAll E= yes Turn to Virginia Senate Race.=E2=80=9D <i>The New York Times</= i>, November 9, 2006, sec. /. <a href=3D"http://hostname/url.">http://hostname/url.</a></= div>
-----------------

Note the final "." in t= he href -- this is a bug in the citeproc-js citation engine (I think).
<= br>So, I would like to do some postprocessing and just remove the final &qu= ot;.".=C2=A0 But it's not obvious to me how to do that.=C2=A0 I fe= el like it should be!=C2=A0 And that for an editor, emacs makes it awfully = hard to match patterns & edit strings.=C2=A0 But I think that's par= tly because I simply understand lisp so poorly.=C2=A0

If some= one could show me how to do this, nad somehow along hte way make me underst= and hte basic principles involved so I can start to teach myself better...= =C2=A0 well, I would appreciate it.

thanks again,
Mat= t

--e89a8fb1e9eca18514050dd5cf83--