emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Matt Price <moptop99@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: help with pattern-matching
Date: Thu, 29 Jan 2015 22:00:46 -0500	[thread overview]
Message-ID: <CAJ51EToD9PDwR0SJganFFtJ85zjgdnu=shz5rUGieeGWW-T7CQ@mail.gmail.com> (raw)
In-Reply-To: <CAN_Dec-6AXUq4yaRG+h87-K0aFEHxG+wqUO7RZm84zCoYtyJfA@mail.gmail.com>

[-- 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 --]

      reply	other threads:[~2015-01-30  3:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30  2:36 help with pattern-matching Matt Price
2015-01-30  3:00 ` John Kitchin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJ51EToD9PDwR0SJganFFtJ85zjgdnu=shz5rUGieeGWW-T7CQ@mail.gmail.com' \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).