Topic: Strip and partition member functions for strings ?


Author: VinceRev <vince.rev@gmail.com>
Date: Sat, 1 Jun 2013 08:38:35 -0700 (PDT)
Raw View
------=_Part_109_5737011.1370101115911
Content-Type: text/plain; charset=ISO-8859-1

Two features that I like and use a lot in python are the strip and
partitions functions (lstrip, rstrip, strip, partition, rpartition) of
strings :
http://docs.python.org/3.3/library/stdtypes.html
It allows convenient manipulations to parse strings with the ability to
chain operations like :

str = "# The answer is : 42 !!!"
print str.partition(":")[2].lstrip(" ").rstrip("!").strip(" ")

with :
partition(":")[2] will return what is after ":" (partition(":")[0] : what
is before ":", partition(":")[1] : the separator itself)
lstrip(" ") will remove the leading spaces
rstrip("!") will remove the trailing "!"
strip(" ") will remove the remaining leading and trailing " "

It may not be the most efficient way to proceed but it is very convenient
and I would like to have similar features in C++.

Consequently I have several questions :
1) Would you like to see such features to manipulate strings and chain
operations in C++ ?
2) Do you think that such functions should return a modified copy of the
string or modify the string itself ?
3) What design would you like for such features ?

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_109_5737011.1370101115911
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Two features that I like and use a lot in python are the strip and partitio=
ns functions (<span style=3D"font-family: courier new,monospace;">lstrip, r=
strip, strip, partition, rpartition</span>) of strings :<br>http://docs.pyt=
hon.org/3.3/library/stdtypes.html<br>It allows convenient manipulations to =
parse strings with the ability to chain operations like :<br><br><span styl=
e=3D"font-family: courier new,monospace;">str =3D "# The answer is : 42 !!!=
"<br>print str.partition(":")[2].lstrip(" ").rstrip("!").strip(" ")</span><=
br><br>with :<br><span style=3D"font-family: courier new,monospace;">partit=
ion(":")[2] <span style=3D"font-family: arial,sans-serif;">will return what=
 is after ":"</span> (partition(":")[0]<span style=3D"font-family: arial,sa=
ns-serif;"> : what is before</span> ":", </span><span style=3D"font-family:=
 courier new,monospace;"><span style=3D"font-family: courier new,monospace;=
">partition(":")[1]<span style=3D"font-family: arial,sans-serif;"> : the se=
parator itself</span></span>)</span><br><span style=3D"font-family: courier=
 new,monospace;">lstrip(" ")</span> will remove the leading spaces<br><span=
 style=3D"font-family: courier new,monospace;">rstrip("!")</span> will remo=
ve the trailing <span style=3D"font-family: courier new,monospace;">"!"</sp=
an><br><span style=3D"font-family: courier new,monospace;">strip(" ")</span=
> will remove the remaining leading and trailing <span style=3D"font-family=
: courier new,monospace;">" "</span><br><br>It may not be the most efficien=
t way to proceed but it is very convenient and I would like to have similar=
 features in C++.<br><br>Consequently I have several questions :<br>1) Woul=
d you like to see such features to manipulate strings and chain operations =
in C++ ?<br>2) Do you think that such functions should return a modified co=
py of the string or modify the string itself ?<br>3) What design would you =
like for such features ?<br><br>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_109_5737011.1370101115911--

.


Author: Marshall Clow <mclow.lists@gmail.com>
Date: Sat, 1 Jun 2013 09:20:20 -0700
Raw View
--Apple-Mail=_B9A44657-48A8-491F-A412-EACD95894F14
Content-Type: text/plain; charset=ISO-8859-1

On Jun 1, 2013, at 8:38 AM, VinceRev <vince.rev@gmail.com> wrote:

> Two features that I like and use a lot in python are the strip and partitions functions (lstrip, rstrip, strip, partition, rpartition) of strings :
> http://docs.python.org/3.3/library/stdtypes.html
> It allows convenient manipulations to parse strings with the ability to chain operations like :
>
> str = "# The answer is : 42 !!!"
> print str.partition(":")[2].lstrip(" ").rstrip("!").strip(" ")
>
> with :
> partition(":")[2] will return what is after ":" (partition(":")[0] : what is before ":", partition(":")[1] : the separator itself)
> lstrip(" ") will remove the leading spaces
> rstrip("!") will remove the trailing "!"
> strip(" ") will remove the remaining leading and trailing " "
>
> It may not be the most efficient way to proceed but it is very convenient and I would like to have similar features in C++.
>
> Consequently I have several questions :
> 1) Would you like to see such features to manipulate strings and chain operations in C++ ?
> 2) Do you think that such functions should return a modified copy of the string or modify the string itself ?
> 3) What design would you like for such features ?

You should look at Jeffrey Yasskin and Greg Miller's proposals for string_view (n3685) and split (n3593) for work in this area.



-- Marshall

Marshall Clow     Idio Software   <mailto:mclow.lists@gmail.com>

A.D. 1517: Martin Luther nails his 95 Theses to the church door and is promptly moderated down to (-1, Flamebait).
        -- Yu Suzuki

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--Apple-Mail=_B9A44657-48A8-491F-A412-EACD95894F14
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=ISO-8859-1

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Diso-8859-1"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mo=
de: space; -webkit-line-break: after-white-space; "><div><div>On Jun 1, 201=
3, at 8:38 AM, VinceRev &lt;<a href=3D"mailto:vince.rev@gmail.com">vince.re=
v@gmail.com</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline"><bl=
ockquote type=3D"cite">Two features that I like and use a lot in python are=
 the strip and partitions functions (<span style=3D"font-family: courier ne=
w,monospace;">lstrip, rstrip, strip, partition, rpartition</span>) of strin=
gs :<br><a href=3D"http://docs.python.org/3.3/library/stdtypes.html">http:/=
/docs.python.org/3.3/library/stdtypes.html</a><br>It allows convenient mani=
pulations to parse strings with the ability to chain operations like :<br><=
br><span style=3D"font-family: courier new,monospace;">str =3D "# The answe=
r is : 42 !!!"<br>print str.partition(":")[2].lstrip(" ").rstrip("!").strip=
(" ")</span><br><br>with :<br><span style=3D"font-family: courier new,monos=
pace;">partition(":")[2] <span style=3D"font-family: arial,sans-serif;">wil=
l return what is after ":"</span> (partition(":")[0]<span style=3D"font-fam=
ily: arial,sans-serif;"> : what is before</span> ":", </span><span style=3D=
"font-family: courier new,monospace;"><span style=3D"font-family: courier n=
ew,monospace;">partition(":")[1]<span style=3D"font-family: arial,sans-seri=
f;"> : the separator itself</span></span>)</span><br><span style=3D"font-fa=
mily: courier new,monospace;">lstrip(" ")</span> will remove the leading sp=
aces<br><span style=3D"font-family: courier new,monospace;">rstrip("!")</sp=
an> will remove the trailing <span style=3D"font-family: courier new,monosp=
ace;">"!"</span><br><span style=3D"font-family: courier new,monospace;">str=
ip(" ")</span> will remove the remaining leading and trailing <span style=
=3D"font-family: courier new,monospace;">" "</span><br><br>It may not be th=
e most efficient way to proceed but it is very convenient and I would like =
to have similar features in C++.<br><br>Consequently I have several questio=
ns :<br>1) Would you like to see such features to manipulate strings and ch=
ain operations in C++ ?<br>2) Do you think that such functions should retur=
n a modified copy of the string or modify the string itself ?<br>3) What de=
sign would you like for such features ?<br>
</blockquote><br></div><div>You should look at Jeffrey Yasskin and Greg Mil=
ler's proposals for string_view (n3685) and split (n3593) for work in this =
area.</div><div><br></div><div><br></div><br><div apple-content-edited=3D"t=
rue">
<span class=3D"Apple-style-span" style=3D"border-collapse: separate; color:=
 rgb(0, 0, 0); font-family: 'Lucida Grande'; font-style: normal; font-varia=
nt: normal; font-weight: normal; letter-spacing: normal; line-height: norma=
l; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; wh=
ite-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-=
spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decoration=
s-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-widt=
h: 0px; font-size: medium; ">-- Marshall<br><br>Marshall Clow &nbsp; &nbsp;=
 Idio Software &nbsp; &lt;<a href=3D"mailto:mclow.lists@gmail.com">mailto:m=
clow.lists@gmail.com</a>&gt;<br><br>A.D. 1517: Martin Luther nails his 95 T=
heses to the church door and is promptly moderated down to (-1, Flamebait).=
<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;-- Yu Suzuki</span>

</div>
<br></body></html>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--Apple-Mail=_B9A44657-48A8-491F-A412-EACD95894F14--

.