Note that there are some explanatory texts on larger screens.

plurals
  1. PORegular expression is is looping the expression and returning it as one result
    primarykey
    data
    text
    <p>I am writing a perl script to generate .cpp files out of .h files using regular expressions to find functions, then using regex again to break the reults into two peices, the return type and the function.</p> <p>I created a regular expression to find the return type which almost works.</p> <pre><code>^(\s*&amp;?\w*\s*(\&lt;{1}.*\&gt;{1})*\s) </code></pre> <p>Edit: I updated the regex string to one that works better, but still no change as far as this question is concerned.</p> <p>This works on most cpp prototypes such as</p> <pre><code>int funky(); int funky(int something); &amp;int funky(int something); &amp;int &lt;vector *&gt; funky(); </code></pre> <p>in these cases the regex matches</p> <pre><code>int int &amp;int &amp;int &lt;vector *&gt; </code></pre> <p>Which is perfect, however in cases where there is a string that matches inside the function arguments, such as:</p> <pre><code>int &lt;vector&gt; funky(int &lt;vector&gt; i); int &lt;vector&gt; funky(int &lt;vector *&gt; i); int &lt;vector&gt; funky(const int &lt;vector&gt; i); </code></pre> <p>The regex matches </p> <pre><code>int &lt;vector&gt; funky(int &lt;vector&gt; int &lt;vector&gt; funky(int &lt;vector *&gt; int &lt;vector&gt; funky(const int &lt;vector&gt; </code></pre> <p>When I want it to return </p> <pre><code>int &lt;vector&gt; int &lt;vector&gt; int &lt;vector&gt; </code></pre> <p>And I can't figure out whey its continuing past the end of the first closing bracket '>'. I am new to regular expressions and simply can't figure this out. </p> <p>Sorry of there is an answer out there for this, I searched and haven't been able to find one, probably cause i don't even know what terms to look for :(.</p> <p>Edit2: If this question is more complicated than I anticipated, could someone explain why it continues on past the first &lt;.*>? I don't see why this doesn't work.</p>
    singulars
    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.
 

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