<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162251</link>
    <title>MATLAB Central Newsreader - REGEXP extract data</title>
    <description>Feed for thread: REGEXP extract data</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>Fri, 18 Jan 2008 19:00:25 -0500</pubDate>
      <title>REGEXP extract data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162251#410054</link>
      <author>Pete sherer</author>
      <description>I have character data like:&lt;br&gt;
&lt;br&gt;
aa = {'BI234','EVB67','C4566','St Vermont','DD'};&lt;br&gt;
How can I use REGEXP to separate the character and the number?&lt;br&gt;
&lt;br&gt;
so &lt;br&gt;
aa1 = {'BI','EVB','C','St Vermont','DD'};&lt;br&gt;
aa2 = {'234','67','4566','',''};;&lt;br&gt;
&lt;br&gt;
Thanks for your suggestions,</description>
    </item>
    <item>
      <pubDate>Fri, 18 Jan 2008 19:26:00 -0500</pubDate>
      <title>Re: REGEXP extract data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162251#410058</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;fmqt09$mtb$1@fred.mathworks.com&amp;gt;, Pete sherer &amp;lt;tsh@abg.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;I have character data like:&lt;br&gt;
&lt;br&gt;
&amp;gt;aa = {'BI234','EVB67','C4566','St Vermont','DD'};&lt;br&gt;
&amp;gt;How can I use REGEXP to separate the character and the number?&lt;br&gt;
&lt;br&gt;
&amp;gt;so &lt;br&gt;
&amp;gt;aa1 = {'BI','EVB','C','St Vermont','DD'};&lt;br&gt;
&amp;gt;aa2 = {'234','67','4566','',''};;&lt;br&gt;
&lt;br&gt;
Well, you could certainly do it with regexp, but if those&lt;br&gt;
strings illustrate the complete range of variations, then why not&lt;br&gt;
use  find(ismember(aa{i}, '0':'9'), 1)  to find the index&lt;br&gt;
of the first digit in aa{i} ? If you need to run over the entire&lt;br&gt;
aa cell, you can either loop or cellfun() with UniformOutput 0 .&lt;br&gt;
Note: the output of the find() will be empty for strings without digits.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&quot;Any sufficiently advanced bug is indistinguishable from a feature.&quot;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;-- Rich Kulawiec</description>
    </item>
    <item>
      <pubDate>Fri, 18 Jan 2008 20:10:18 -0500</pubDate>
      <title>Re: REGEXP extract data</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/162251#410068</link>
      <author>Jason Breslau</author>
      <description>Assuming your data is all non-digits, followed by digits, try using &lt;br&gt;
named tokens:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;gt;&amp;gt; names = regexp(aa, '^(?&amp;lt;aa1&amp;gt;\D*+)(?&amp;lt;aa2&amp;gt;\d*+)$', 'names');&lt;br&gt;
&amp;nbsp;&amp;gt;&amp;gt; names = [names{:}];&lt;br&gt;
&amp;nbsp;&amp;gt;&amp;gt; aa1 = {names.aa1}&lt;br&gt;
&lt;br&gt;
aa1 =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'BI'    'EVB'    'C'    'St Vermont'    'DD'&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;gt;&amp;gt; aa2 = {names.aa2}&lt;br&gt;
&lt;br&gt;
aa2 =&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'234'    '67'    '4566'     ''     ''&lt;br&gt;
&lt;br&gt;
-=&amp;gt;J</description>
    </item>
  </channel>
</rss>

