all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* split-string case insensitive?
@ 2008-08-10 14:10 pwl_b
  2008-08-10 15:24 ` Pascal J. Bourguignon
  0 siblings, 1 reply; 3+ messages in thread
From: pwl_b @ 2008-08-10 14:10 UTC (permalink / raw)
  To: help-gnu-emacs

Hi!

I am trying to split a string in eLisp using split-string, and here is
a sample outcome of it:

(split-string "Abcade" "A" t)
=> ("bc" "de")

The question is: Why it does not care about case of "A"? And is there
a way to split string in case-sensitive manner?

The strange thing to me is that split-string does accept regexp as a
separator, but it still doesn't care about the cases e.g.:

(split-string "A1ba2b" "A." t)
=> ("b" "b")

I would appreciate any help given, and I am sorry if this question has
an obvious answer but I couldn't find any on the Web.

Regards,
Paweł.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: split-string case insensitive?
  2008-08-10 14:10 split-string case insensitive? pwl_b
@ 2008-08-10 15:24 ` Pascal J. Bourguignon
  2008-08-11  8:40   ` pwl_b
  0 siblings, 1 reply; 3+ messages in thread
From: Pascal J. Bourguignon @ 2008-08-10 15:24 UTC (permalink / raw)
  To: help-gnu-emacs

pwl_b <Pawel.Biernat@gmail.com> writes:

> Hi!
>
> I am trying to split a string in eLisp using split-string, and here is
> a sample outcome of it:
>
> (split-string "Abcade" "A" t)
> => ("bc" "de")
>
> The question is: Why it does not care about case of "A"? And is there
> a way to split string in case-sensitive manner?
>
> The strange thing to me is that split-string does accept regexp as a
> separator, but it still doesn't care about the cases e.g.:
>
> (split-string "A1ba2b" "A." t)
> => ("b" "b")
>
> I would appreciate any help given, and I am sorry if this question has
> an obvious answer but I couldn't find any on the Web.

It depends on the setting of the case-fold-search variable:

(let ((case-fold-search t))
  (split-string "Abcade" "A" t)) --> ("bc" "de")

(let ((case-fold-search nil))
  (split-string "Abcade" "A" t)) --> ("bcade")

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

In a World without Walls and Fences, 
who needs Windows and Gates?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: split-string case insensitive?
  2008-08-10 15:24 ` Pascal J. Bourguignon
@ 2008-08-11  8:40   ` pwl_b
  0 siblings, 0 replies; 3+ messages in thread
From: pwl_b @ 2008-08-11  8:40 UTC (permalink / raw)
  To: help-gnu-emacs

On 10 Sie, 17:24, p...@informatimago.com (Pascal J. Bourguignon)
wrote:
> pwl_b <Pawel.Bier...@gmail.com> writes:
> > Hi!
>
> > I am trying to split a string in eLisp using split-string, and here is
> > a sample outcome of it:
>
> > (split-string "Abcade" "A" t)
> > => ("bc" "de")
>
> > The question is: Why it does not care about case of "A"? And is there
> > a way to split string in case-sensitive manner?
>
> > The strange thing to me is that split-string does accept regexp as a
> > separator, but it still doesn't care about the cases e.g.:
>
> > (split-string "A1ba2b" "A." t)
> > => ("b" "b")
>
> > I would appreciate any help given, and I am sorry if this question has
> > an obvious answer but I couldn't find any on the Web.
>
> It depends on the setting of the case-fold-search variable:
>
> (let ((case-fold-search t))
>   (split-string "Abcade" "A" t)) --> ("bc" "de")
>
> (let ((case-fold-search nil))
>   (split-string "Abcade" "A" t)) --> ("bcade")
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> In a World without Walls and Fences,
> who needs Windows and Gates?

It does work! Thanks a lot!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-08-11  8:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-10 14:10 split-string case insensitive? pwl_b
2008-08-10 15:24 ` Pascal J. Bourguignon
2008-08-11  8:40   ` pwl_b

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.