Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can you yank/print the match from a regular expression and only the match of a regular expression?
    text
    copied!<p>I have a whole bunch of variable names that I need to move around between migration files, views, locale files and so forth.</p> <p>I don't want to re-type all of these, nor do I want to copy, paste and trim because I have done too much of that.</p> <p>I have been trying to pull these out through a regular expression but every time I try to do so, the entire line is printed instead of just the variable name I want that begin with ':' and end with '\s' as in: :name, :email, :home_phone, etc.</p> <p>How can I get these to just extract out what I want?</p> <p>I've been trying to do this in vim with:</p> <pre><code> :%s/:.*\s/y </code></pre> <p>Here's the input file:</p> <pre><code> &lt;%= f.input :name %&gt; &lt;%= f.input :email %&gt; &lt;%= f.input :home_phone %&gt; &lt;%= f.input :cell_phone %&gt; &lt;%= f.input :other_phones %&gt; &lt;%= f.input :last_position_candidate_id %&gt; &lt;%= f.input :last_position_title %&gt; &lt;%= f.input :last_position_company_id %&gt; &lt;%= f.input :last_position_start_date %&gt; &lt;%= f.input :last_position_salary %&gt; &lt;%= f.input :last_position_medical_insurance %&gt; &lt;%= f.input :last_position_christmas_bonus %&gt; &lt;%= f.input :last_position_annual_bonus %&gt; &lt;%= f.input :last_position_vehicle %&gt; &lt;%= f.input :last_position_other_benefits %&gt; &lt;%= f.input :conversational_english %&gt; &lt;%= f.input :written_english %&gt; &lt;%= f.input :vehicle %&gt; </code></pre> <p>This is what I would like to get:</p> <pre><code> :name :email :home_phone :cell_phone :other_phones :last_position_candidate_id :last_position_title :last_position_company_id :last_position_start_date :last_position_salary :last_position_medical_insurance :last_position_christmas_bonus :last_position_annual_bonus :last_position_vehicle :last_position_other_benefits :conversational_english :written_english :vehicle </code></pre>
 

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