Extract a substring in Ruby using a regular expression
<p>How can I extract a substring from within a string as field name in Ruby?</p>

<p>output Example:</p>

<pre><code>A-field:name.23.134 =&gt; 6

ruby {
        code =&gt; "

             if key =~ /^A-field:[A-Za-z]+/ then
                     #how to get the match pattern ?and the field value ?                     

               end


}
</code></pre>

<p>how to get the match pattern as field anme and the field value ,
after filter ,it's will be looks like </p>

<p>A-field:name  => 6</p>