<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/98133</link>
    <title>MATLAB Central Newsreader - easy string manipolation</title>
    <description>Feed for thread: easy string manipolation</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 16 Jun 2005 17:20:34 -0400</pubDate>
      <title>easy string manipolation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/98133#249036</link>
      <author>gigio</author>
      <description>Sorry for the easy question...&lt;br&gt;
&lt;br&gt;
I have some strings like these&lt;br&gt;
dummy='a, b'&lt;br&gt;
dummy='a ,b'&lt;br&gt;
dummy='a b'&lt;br&gt;
dummy='a,b'&lt;br&gt;
&lt;br&gt;
first and second terms are separated by space OR/AND comma&lt;br&gt;
I wish to separate first adn second term of the string &lt;br&gt;
&lt;br&gt;
This is my solution&lt;br&gt;
----&lt;br&gt;
[first,second]=strtok(dummy,' ,')&lt;br&gt;
idx=find (second==',' |isspace(second) );&lt;br&gt;
second(idx)=[];&lt;br&gt;
&lt;br&gt;
first&lt;br&gt;
second&lt;br&gt;
----&lt;br&gt;
It works, but it is not easy to generalize for string with 'n' terms&lt;br&gt;
Any hint ??&lt;br&gt;
&lt;br&gt;
Thank you very much!!</description>
    </item>
    <item>
      <pubDate>Thu, 16 Jun 2005 16:05:10 -0400</pubDate>
      <title>Re: easy string manipolation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/98133#249075</link>
      <author>quo</author>
      <description>gigio wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Sorry for the easy question...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have some strings like these&lt;br&gt;
&amp;gt; dummy='a, b'&lt;br&gt;
&amp;gt; dummy='a ,b'&lt;br&gt;
&amp;gt; dummy='a b'&lt;br&gt;
&amp;gt; dummy='a,b'&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; first and second terms are separated by space OR/AND comma&lt;br&gt;
&amp;gt; I wish to separate first adn second term of the string&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; This is my solution&lt;br&gt;
&amp;gt; ----&lt;br&gt;
&amp;gt; [first,second]=strtok(dummy,' ,')&lt;br&gt;
&amp;gt; idx=find (second==',' |isspace(second) );&lt;br&gt;
&amp;gt; second(idx)=[];&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; first&lt;br&gt;
&amp;gt; second&lt;br&gt;
&amp;gt; ----&lt;br&gt;
&amp;gt; It works, but it is not easy to generalize for string with 'n'&lt;br&gt;
&amp;gt; terms&lt;br&gt;
&amp;gt; Any hint ??&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you very much!!&lt;br&gt;
&amp;gt;&lt;br&gt;
&lt;br&gt;
well, this is messy and regexps would probably work well here, but...&lt;br&gt;
&lt;br&gt;
rema = strrep(dummy,',',' ');&lt;br&gt;
cnt = 0;&lt;br&gt;
while ~isempty(rema)&lt;br&gt;
cnt = cnt+1;&lt;br&gt;
[element{cnt}, rema] = strtok(rema,' ');&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
hth&lt;br&gt;
-quo</description>
    </item>
    <item>
      <pubDate>Thu, 16 Jun 2005 20:13:47 -0400</pubDate>
      <title>Re: easy string manipolation</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/98133#249078</link>
      <author>gigio</author>
      <description>On Thu, 16 Jun 2005 16:05:10 -0400, quo &amp;lt;none@email.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;gigio wrote:&lt;br&gt;
&amp;gt;&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;rema = strrep(dummy,',',' ');&lt;br&gt;
&amp;gt;cnt = 0;&lt;br&gt;
&amp;gt;while ~isempty(rema)&lt;br&gt;
&amp;gt;cnt = cnt+1;&lt;br&gt;
&amp;gt;[element{cnt}, rema] = strtok(rema,' ');&lt;br&gt;
&amp;gt;end&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;hth&lt;br&gt;
&amp;gt;-quo&lt;br&gt;
&lt;br&gt;
OK! Thanks!</description>
    </item>
  </channel>
</rss>

