* help with pattern-matching
@ 2015-01-30 2:36 Matt Price
2015-01-30 3:00 ` John Kitchin
0 siblings, 1 reply; 2+ messages in thread
From: Matt Price @ 2015-01-30 2:36 UTC (permalink / raw)
To: Org Mode
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
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 back
from Zotero in a form like this:
-----------------
<div class="csl-entry">Broder, John M., and Ian Urbina. “All Eyes Turn to
Virginia Senate Race.” <i>The New York Times</i>, November 9, 2006, sec. /.
<a href="http://hostname/url.">http://hostname/url.</a></div>
-----------------
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! And
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 me
understand hte basic principles involved so I can start to teach myself
better... well, I would appreciate it.
thanks again,
Matt
[-- Attachment #2: Type: text/html, Size: 1340 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: help with pattern-matching
2015-01-30 2:36 help with pattern-matching Matt Price
@ 2015-01-30 3:00 ` John Kitchin
0 siblings, 0 replies; 2+ messages in thread
From: John Kitchin @ 2015-01-30 3:00 UTC (permalink / raw)
To: Matt Price; +Cc: Org Mode
[-- Attachment #1: Type: text/plain, Size: 2274 bytes --]
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 " <div class=\"csl-entry\">Broder, John M., and Ian Urbina. “All
Eyes Turn to Virginia Senate Race.” <i>The New York Times</i>, November 9,
2006, sec. /. <a
href=\"http:hostname/url.\">http://hostname/url.</a></div>"))
(setq s (replace-regexp-in-string "\\(\.\\)\"" "" s nil nil 1))
(setq s (replace-regexp-in-string "\\(\.\\)</a>" "" s nil nil 1)))
#+END_SRC
#+RESULTS:
: <div class"csl-entr">Broder, John M., and Ian Urbina. “All Eyes Turn to
Virginia Senate Race.” <i>The New York Times</i>, November 9, 2006, sec. /.
<a href"http:hostname/url">http://hostname/url</a></div>
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 <moptop99@gmail.com> 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 back
> from Zotero in a form like this:
>
> -----------------
> <div class="csl-entry">Broder, John M., and Ian Urbina. “All Eyes Turn
> to Virginia Senate Race.” <i>The New York Times</i>, November 9, 2006, sec.
> /. <a href="http://hostname/url.">http://hostname/url.</a></div>
> -----------------
>
> 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! And
> 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 me
> understand hte basic principles involved so I can start to teach myself
> better... well, I would appreciate it.
>
> thanks again,
> Matt
>
[-- Attachment #2: Type: text/html, Size: 3363 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-30 3:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-30 2:36 help with pattern-matching Matt Price
2015-01-30 3:00 ` John Kitchin
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.