title: Selecting elements in numpy array using regular expressions
body: <p>One may select elements in numpy arrays as follows</p>
  
  <pre><code>a = np.random.rand(100)
  sel = a &gt; 0.5 #select elements that are greater than 0.5
  a[sel] = 0 #do something with the selection
  
  b = np.array(list('abc abc abc'))
  b[b==a] = 'A' #convert all the a's to A's
  </code></pre>
  
  <p>This property is used by the <code>np.where</code> function to retrive indices:</p>
  
  <pre><code>indices = np.where(a&gt;0.9)
  </code></pre>
  
  <p>What I would like to do is to be able to use regular expressions in such element selection. For example, if I want to select elements from <code>b</code> above that match the <code>[Aab]</code> regexp, I need to write the following code:</p>
  
  <pre><code>regexp = '[Ab]'
  selection = np.array([bool(re.search(regexp, element)) for element in b])
  </code></pre>
  
  <p>This looks too verbouse for me. Is there any shorter and more elegant way to do this?</p>