all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Luis O. Silva" <silva@paloma.spbu.ru>
Cc: help-gnu-emacs@gnu.org
Subject: Re: a function for string splitting
Date: Tue, 26 Nov 2002 22:59:28 +0300	[thread overview]
Message-ID: <15843.53920.300970.277865@localhost.localdomain> (raw)
In-Reply-To: <m3r8d8jsir.fsf@mika.informatik.uni-freiburg.de>

Dear Lee,

On 26 Nov 2002 15:49:00 +0100, Lee Sau Dan writes:

   Luis> My question is what function I could use for
   Luis> correctly splitting the string.

   Luis> Please be indulgent with me since

   Luis> 1. I'm not a programmer 2. I don't have access to the
   Luis> elisp manual even on-line (my connection is very
   Luis> slow, only sufficient to download my e-mail).

   Lee> Consider learning "regular expressions", which are not
   Lee> only useful in Emacs, but also useful throughout the
   Lee> unix environment (e.g. grep, sed, awk, vi, ...).

   Lee> Try:

   Lee> (let ((date-string "Thu, 21 Nov 2002 16:05:50 -0600")
   Lee>       (regex-fragment-1 "\\([A-Z][a-z]*\\), ")
   Lee>       (regex-fragment-2 "\\([0-9]+\\)\\([A-Z][a-z]*\\)\\([0-9]+\\) ")
   Lee>       (regex-fragment-3 "\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\) ")
   Lee>       (regex-fragment-4 "\\([+-][0-9]*\\)" ))
   Lee>   (if (string-match (concat regex-fragment-1
   Lee>                             regex-fragment-2
   Lee>                             regex-fragment-3
   Lee>                             regex-fragment-4)
   Lee>                     date-string)
   Lee>     (let ((day-of-week (match-string 1 date-string))
   Lee>           (day (match-string 2 date-string))
   Lee>           (month-name (match-string 3 date-string))
   Lee>           (year (match-string 4 date-string))
   Lee>           (hour (match-string 5 date-string))
   Lee>           (minute (match-string 6 date-string))
   Lee>           (second (match-string 7 date-string))
   Lee>           (tz-spec (match-string 8 date-string)))

   Lee>     (list day month-name year hour minute second tz-spec))))

Thank you very much. This is just what I needed. I have an
incipient notion of regular expressions and I had used them to
do search in buffers. I didn't know of the existence of the
function `string-match'.

   Lee> Note that I've broken up the regex into 4 fragments to
   Lee> make it usenet friendly, rejoining them with (concat
   Lee> ...).  This is not really necessary.

Yes, it is not necessary but this nicety will also be useful
for me. Thanks a lot.

Regards,
luis

-- 
Luis Octavio Silva P.
St. Petersburg State University.
66/3 Botanicheskaya St., Apt.119/2
Stary Peterhof
St. Petersburg, Russia.

  reply	other threads:[~2002-11-26 19:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1038319044.17125.help-gnu-emacs@gnu.org>
2002-11-26 14:49 ` a function for string splitting Lee Sau Dan
2002-11-26 19:59   ` Luis O. Silva [this message]
2002-11-26 15:56 ` Daniel Jensen
2002-11-26 20:25   ` Luis O. Silva
     [not found]   ` <mailman.1038341287.29557.help-gnu-emacs@gnu.org>
2002-11-28 14:14     ` Kai Großjohann
2002-11-28 18:21       ` Luis O. Silva
     [not found]       ` <mailman.1038506557.25888.help-gnu-emacs@gnu.org>
2002-11-28 18:30         ` Benjamin Lewis
2002-11-28 18:50         ` Kai Großjohann
2002-11-29  7:03           ` Luis O. Silva
2002-11-26 20:14 Greg Hill
2002-11-27  5:40 ` Luis O. Silva
  -- strict thread matches above, loose matches on Subject: below --
2002-11-26 14:16 Luis O. Silva
2002-11-26 20:03 ` Greg Hill

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

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

  git send-email \
    --in-reply-to=15843.53920.300970.277865@localhost.localdomain \
    --to=silva@paloma.spbu.ru \
    --cc=help-gnu-emacs@gnu.org \
    /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 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.