Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In your specific case a way to perform this with regular expressions would be:</p> <p>First you have to decide what strings are valid in your search for example:</p> <pre><code>firstpar = 'First parameter is [0-9]+'; </code></pre> <p>means that you are looking for a string <em>'First parameter is '</em><br> that ends with a <strong>sequence of digits</strong>. </p> <p>Then you could use <code>regexp</code> or <code>regexpi</code> in the following way:</p> <pre><code>results = regexp(mystring, firstpar, 'match'); </code></pre> <p>Where <code>mystring</code> is the text you perform the search on and <code>'match'</code> means that you want parts of the text as output, not indexes. </p> <p>Now, <code>results</code> is a cell matrix with each cell containing a string that appeared in your text and fulfilled your <code>firstpar</code> definition. In order to extract just the numbers from cell matrix of strings you could use <code>regexp</code> again, but now helping yourself with <code>cellfun</code>, which iteratively applies your command to all cells of a cell matrix: </p> <pre><code>numbers = cellfun(@(x) str2num(regexp(x, '[0-9]+', 'match', 'once')), results); </code></pre> <p><code>numbers</code> is an array of numbers that you were looking for. </p> <p>You can do the same for different string patterns - if you want to have a more general string definitions (instead of straightforward <code>firstpar</code> that we used here) read <a href="http://www.mathworks.com/help/matlab/ref/regexpi.html" rel="nofollow">matlab documentation about regular expressions</a> (alexcasalboni pasted it in his comment), scroll down to Input Arguments and expand 'expressions'. </p> <p>The difference between <code>regexp</code> and <code>regexpi</code> is that the latter is case insensitive.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload