<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208</link>
    <title>MATLAB Central Newsreader - simple regexp question</title>
    <description>Feed for thread: simple regexp question</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>Tue, 12 Aug 2008 16:13:01 -0400</pubDate>
      <title>simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448724</link>
      <author>matt dash</author>
      <description>Hello,&lt;br&gt;
&lt;br&gt;
I have a cell array of strings, each of which looks like :&lt;br&gt;
&lt;br&gt;
'Lambda46' =&amp;gt; '54.954684760469313', &lt;br&gt;
&lt;br&gt;
(including the quotes and comma) and I want to extract the&lt;br&gt;
two numbers 46 and 54.954... and put them in vectors.&lt;br&gt;
Normally I would do this by finding the locations of the&lt;br&gt;
quotes and working from there, but I suspect there's a&lt;br&gt;
better way using regular expressions and I figure it's about&lt;br&gt;
time I started using them... is there a simple way to do this?</description>
    </item>
    <item>
      <pubDate>Tue, 12 Aug 2008 16:20:59 -0400</pubDate>
      <title>Re: simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448726</link>
      <author>Clemens Winkler</author>
      <description>On 12 Aug., 18:13, &quot;matt dash&quot; &amp;lt;n...@mail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I have a cell array of strings, each of which looks like :&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 'Lambda46' =&amp;gt; '54.954684760469313',&lt;br&gt;
&lt;br&gt;
You should give more informations. Do they all look like&lt;br&gt;
'Lambdaxx' =&amp;gt; 'xxx',&lt;br&gt;
??&lt;br&gt;
&lt;br&gt;
Or are there any other characters as well?? Is it always Lambda?&lt;br&gt;
&lt;br&gt;
Clemens</description>
    </item>
    <item>
      <pubDate>Tue, 12 Aug 2008 16:30:22 -0400</pubDate>
      <title>Re: simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448727</link>
      <author>roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)</author>
      <description>In article &amp;lt;g7scqd$lbp$1@fred.mathworks.com&amp;gt;, matt dash &amp;lt;n.a@mail.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt;I have a cell array of strings, each of which looks like :&lt;br&gt;
&lt;br&gt;
&amp;gt;'Lambda46' =&amp;gt; '54.954684760469313', &lt;br&gt;
&lt;br&gt;
&amp;gt;(including the quotes and comma) and I want to extract the&lt;br&gt;
&amp;gt;two numbers 46 and 54.954... and put them in vectors.&lt;br&gt;
&amp;gt;Normally I would do this by finding the locations of the&lt;br&gt;
&amp;gt;quotes and working from there, but I suspect there's a&lt;br&gt;
&amp;gt;better way using regular expressions and I figure it's about&lt;br&gt;
&amp;gt;time I started using them... is there a simple way to do this?&lt;br&gt;
&lt;br&gt;
You don't quite give enough information about the form of the&lt;br&gt;
numbers, and you don't give us any information about whether&lt;br&gt;
there can be digits in the identifier before the trailing digits&lt;br&gt;
that you want to extract (e.g., 'Rom3Gam17')&lt;br&gt;
&lt;br&gt;
(\d+).*((?:\d+(?:\.\d*))|(?:\.\d+))&lt;br&gt;
&lt;br&gt;
The above expression assumes that the two set of digits&lt;br&gt;
on the line are to be extracted. It allows three forms&lt;br&gt;
for the second number: an integer with no decimal place;&lt;br&gt;
or a fixed-point number with digits followed by decimal point&lt;br&gt;
optionally followed by digits; or a fixed-point number that starts&lt;br&gt;
immediately with a decimal point followed by {mandatory} digits.&lt;br&gt;
It does not allow the second &quot;number&quot; to consistent entirely of&lt;br&gt;
a decimal point with no digits. The complexity of the expression&lt;br&gt;
could potentially be much reduced if it was known that some&lt;br&gt;
of these forms never occur.&lt;br&gt;
-- &lt;br&gt;
&amp;nbsp;&amp;nbsp;&quot;What is important, then, is not that the critic should possess a&lt;br&gt;
&amp;nbsp;&amp;nbsp;correct abstract definition of beauty for the intellect, but a&lt;br&gt;
&amp;nbsp;&amp;nbsp;certain kind of temperament, the power of being deeply moved by&lt;br&gt;
&amp;nbsp;&amp;nbsp;the presence of beautiful objects.&quot;         -- Walter Pater</description>
    </item>
    <item>
      <pubDate>Tue, 12 Aug 2008 16:34:03 -0400</pubDate>
      <title>Re: simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448729</link>
      <author>matt dash</author>
      <description>Clemens Winkler &amp;lt;ClemensWinkler@gmx.net&amp;gt; wrote in message&lt;br&gt;
&amp;lt;a735e4fc-1249-4065-92cd-132d2f9b7fb9@m73g2000hsh.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; On 12 Aug., 18:13, &quot;matt dash&quot; &amp;lt;n...@mail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hello,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; I have a cell array of strings, each of which looks like :&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 'Lambda46' =&amp;gt; '54.954684760469313',&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You should give more informations. Do they all look like&lt;br&gt;
&amp;gt; 'Lambdaxx' =&amp;gt; 'xxx',&lt;br&gt;
&amp;gt; ??&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Or are there any other characters as well?? Is it always&lt;br&gt;
Lambda?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Clemens&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
yes the only thing that changes is the numbers, which are&lt;br&gt;
random and of arbitrary length.</description>
    </item>
    <item>
      <pubDate>Tue, 12 Aug 2008 17:33:47 -0400</pubDate>
      <title>Re: simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448747</link>
      <author>Doug Schwarz</author>
      <description>In article &amp;lt;g7scqd$lbp$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;nbsp;&quot;matt dash&quot; &amp;lt;n.a@mail.com&amp;gt; wrote:&lt;br&gt;
&lt;br&gt;
&amp;gt; Hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I have a cell array of strings, each of which looks like :&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; 'Lambda46' =&amp;gt; '54.954684760469313', &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (including the quotes and comma) and I want to extract the&lt;br&gt;
&amp;gt; two numbers 46 and 54.954... and put them in vectors.&lt;br&gt;
&amp;gt; Normally I would do this by finding the locations of the&lt;br&gt;
&amp;gt; quotes and working from there, but I suspect there's a&lt;br&gt;
&amp;gt; better way using regular expressions and I figure it's about&lt;br&gt;
&amp;gt; time I started using them... is there a simple way to do this?&lt;br&gt;
&lt;br&gt;
I know you asked for a solution using regular expressions, but really &lt;br&gt;
this sort of problem is ideal for textscan.  Suppose your cell array of &lt;br&gt;
strings is C, then&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;str = sprintf('%s\n',C{:});&lt;br&gt;
&amp;nbsp;&amp;nbsp;a = textscan(str,'''Lambda%n'' =&amp;gt; ''%n'',');&lt;br&gt;
&amp;nbsp;&amp;nbsp;col1 = a{1};&lt;br&gt;
&amp;nbsp;&amp;nbsp;col2 = a{2};&lt;br&gt;
&lt;br&gt;
will give you all the first numbers in a vector, col1, and all the &lt;br&gt;
second numbers in a vector, col2.&lt;br&gt;
&lt;br&gt;
-- &lt;br&gt;
Doug Schwarz&lt;br&gt;
dmschwarz&amp;ieee,org&lt;br&gt;
Make obvious changes to get real email address.</description>
    </item>
    <item>
      <pubDate>Tue, 12 Aug 2008 17:45:04 -0400</pubDate>
      <title>Re: simple regexp question</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/174208#448753</link>
      <author>matt dash</author>
      <description>Doug Schwarz &amp;lt;see@sig.for.address.edu&amp;gt; wrote in message&lt;br&gt;
&amp;lt;see-B4663B.13334712082008@softbank060082049208.bbtec.net&amp;gt;...&lt;br&gt;
&amp;gt; In article &amp;lt;g7scqd$lbp$1@fred.mathworks.com&amp;gt;,&lt;br&gt;
&amp;gt;  &quot;matt dash&quot; &amp;lt;n.a@mail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Hello,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I have a cell array of strings, each of which looks like :&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; 'Lambda46' =&amp;gt; '54.954684760469313', &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; (including the quotes and comma) and I want to extract the&lt;br&gt;
&amp;gt; &amp;gt; two numbers 46 and 54.954... and put them in vectors.&lt;br&gt;
&amp;gt; &amp;gt; Normally I would do this by finding the locations of the&lt;br&gt;
&amp;gt; &amp;gt; quotes and working from there, but I suspect there's a&lt;br&gt;
&amp;gt; &amp;gt; better way using regular expressions and I figure it's about&lt;br&gt;
&amp;gt; &amp;gt; time I started using them... is there a simple way to do&lt;br&gt;
this?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I know you asked for a solution using regular expressions,&lt;br&gt;
but really &lt;br&gt;
&amp;gt; this sort of problem is ideal for textscan.  Suppose your&lt;br&gt;
cell array of &lt;br&gt;
&amp;gt; strings is C, then&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   str = sprintf('%s\n',C{:});&lt;br&gt;
&amp;gt;   a = textscan(str,'''Lambda%n'' =&amp;gt; ''%n'',');&lt;br&gt;
&amp;gt;   col1 = a{1};&lt;br&gt;
&amp;gt;   col2 = a{2};&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; will give you all the first numbers in a vector, col1, and&lt;br&gt;
all the &lt;br&gt;
&amp;gt; second numbers in a vector, col2.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -- &lt;br&gt;
&amp;gt; Doug Schwarz&lt;br&gt;
&amp;gt; dmschwarz&amp;ieee,org&lt;br&gt;
&amp;gt; Make obvious changes to get real email address.&lt;br&gt;
&lt;br&gt;
Thanks, thats just what I was looking for. </description>
    </item>
  </channel>
</rss>

