[cl-ppcre-devel] omitting initial void string in split returns

I want to parse strings of space-separated integers, and split is perfect except when I have vertical aligned integers. In such cases I've got one or more spaces at beginning of string, and the resulting list has a void string as 1st element: CL-USER> (cl-ppcre:split "\\s+" " 43 76 87 33 89 ") ("" "43" "76" "87" "33" "89") Is there an option to avoid such initial void string? Thanks. Mario

I don't think there is (unless you want the initial space to be a part of the first string like " 43"). The easiest solution would be to call something like REMOVE-IF or DELETE-IF directly afterwards. Cheers, Edi. On Fri, Apr 13, 2012 at 12:03 PM, Mario Maio <mario.maio@libero.it> wrote:
I want to parse strings of space-separated integers, and split is perfect except when I have vertical aligned integers. In such cases I've got one or more spaces at beginning of string, and the resulting list has a void string as 1st element:
CL-USER> (cl-ppcre:split "\\s+" " 43 76 87 33 89 ")
("" "43" "76" "87" "33" "89")
Is there an option to avoid such initial void string?
Thanks.
Mario
_______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel

How about using (string-trim " " " 43 76 87 33 89 ") first and then doing split? See http://cl-cookbook.sourceforge.net/strings.html#trim Noldus
From: edi@agharta.de Date: Fri, 13 Apr 2012 13:58:27 +0200 To: cl-ppcre-devel@common-lisp.net Subject: Re: [cl-ppcre-devel] omitting initial void string in split returns
I don't think there is (unless you want the initial space to be a part of the first string like " 43"). The easiest solution would be to call something like REMOVE-IF or DELETE-IF directly afterwards.
Cheers, Edi.
On Fri, Apr 13, 2012 at 12:03 PM, Mario Maio <mario.maio@libero.it> wrote:
I want to parse strings of space-separated integers, and split is perfect except when I have vertical aligned integers. In such cases I've got one or more spaces at beginning of string, and the resulting list has a void string as 1st element:
CL-USER> (cl-ppcre:split "\\s+" " 43 76 87 33 89 ")
("" "43" "76" "87" "33" "89")
Is there an option to avoid such initial void string?
Thanks.
Mario
_______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
_______________________________________________ cl-ppcre-devel site list cl-ppcre-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-ppcre-devel
participants (3)
-
Edi Weitz
-
Mario Maio
-
Noldus Reijnders