Filter array using regex in React.js?
<p>I want to be able to check and see which keys start with the letters "gra" and only return that content. I've tried a few things with the code below. In one approach I added something like {key.match(/gra/g)} in the return html but it is not very efficient (and still outputs blank content). I've also tried adding something like this:</p>

<pre><code>  if(String(this.props.profile[key]).match(/gra/g)))
</code></pre>

<p>also tried:</p>

<pre><code>  if(this.props.profile[key].match(/gra/g))
</code></pre>

<p>but keep getting errors like ".match" is not a function or can't read undefined, etc. I've tried various other ways but can't seem to get it working right.</p>

<pre><code>   var grapes = Object.keys(this.props.profile).map(function(key) {
        if(this.props.profile[key] !=null) {
                return (
                     &lt;li key={key} className="example-class"&gt;
                         &lt;label&gt;{key}:&lt;/label&gt;{ this.props.profile[key] }
                      &lt;/li&gt;
                  );
              }
    }, this);


    &lt;html&gt;
       {grapes}
    &lt;/html&gt;
</code></pre>

<p>So, all that to say, what is the best way to filter using regex for something like this?</p>