https://github.com/ichimal/petit.string-utils.git
git clone 'https://github.com/ichimal/petit.string-utils.git'
(ql:quickload :petit.string-utils)
A petit toolbox about string modification.
PETIT.STRING-UTILS
PSU
and PETIT.SU
COERCE-STRING
coece-string
object ⇒ string
To coerce to CL:STRING
from a lisp object.
a string, a character, a symbol, and a number.
not applied recursively.
you can register coercing method for your own types and/or classes.
STRING-++
coece-string
&rest objects ⇒ string
To concatenate given objects to a CL:STRING
object.
COERCE-STRING
will be applied to each of given objects recursively.
CL:LIST
,CL:VECTOR
.CL:ARRAY
, which is not a vector.STRING-++2
string-++2
pre-object post-object ⇒ string
A binary function version of the STRING-++
for CL:APPLY
, CL:FUNCALL
and CL:REDUCE
.
HEAD-MATCH-P
head-match-p
item whole-string ⇒ (or null fixnum)
HEAD-MATCH-P
tests whether the item is same to head part of the whole-string.
When test matched, HEAD-MATCH-P
returns the length of item.
When test does not matched, HEAD-MATCH-P
returns NIL
.
TAIL-MATCH-P
head-match-p
item whole-string ⇒ (or null fixnum)
TAIL-MATCH-P
tests whether the item is same to tail part of the whole-string.
When test matched, TAIL-MATCH-P
returns the matched index (0-based).
When test does not matched, TAIL-MATCH-P
returns NIL
.
STRING-##
string-##
item whole-string ⇒ (values CL:STRING
modified-or-not-p)
STRING-##
removes item from head part of the whole-string, if matched.
STRING-%%
string-%%
item whole-string ⇒ (values CL:STRING
modified-or-not-p)
STRING-%%
removes item from tail part of the whole-string, if matched.
HEAD-MATCH-P
, TAIL-MATCH-P
, STRING-##
and STRING-%%
When the all given arguments are CL:STRING
object, these functions jut work as described above.
When the given item is not a CL:STRING
object, these functions recursively apply COERCE-STRING
to item before testing.
When the given whole-string is not a CL:STRING
object, same as item.
Currently, this toolbox does not support any kind of regular expression.
> (psu:string-++ "pi" '= pi)
"pi=3.1415926535897932385L0"
> (psu:string-++ #\a "Bc" 'd '(1 2 #(3 4)) 5 6)
"aBcD123456"
> (string-## "foo" "foobarbaz")
"barbaz" ;
t
> (string-%% "baz" "foobarbaz")
"foobar" ;
t
> (string-## "baz" "foobarbaz")
"foobarbaz" ;
nil
> (string-%% "foo" "foobarbaz")
"foobarbaz" ;
nil
> (string-## 3 pi)
".1415926535897932385L0" ;
t
SUZUKI Shingo (r2.ichimal@gmail.com)
Copyright (C) 2014 SUZUKI Shingo (r2.ichimal@gmail.com)
Under MIT license.