Question: I tried doing this in python, but I get an error:

```
import numpy as np
array_to_filter = np.array([1,2,3,4,5])
equal_array = np.array([1,2,5,5,5])
array_to_filter[equal_array]

```

and this results in:

```
IndexError: index 5 is out of bounds for axis 0 with size 5

```

What gives? I thought I was doing the right operation here.

I am expecting that if I do

```
array_to_filter[equal_array]

```

That it would return

```
np.array([1,2,5])

```

If I am not on the right track, how would I get it to do that?

Answer: 
The regex: <http://regexr.com/3dr56>

Will match any nodes that consist of say the following:

`<div>hello world</div>`

Provided that the parameters passed to the function:

```js
function removeNode(str, nodeName) {
   var pattern = '<'+nodeName+'>[\\s\\w]+<\/'+nodeName+'>';
   var regex = new RegExp(pattern, 'gi');
   return str.replace(regex, '').replace(/^\s*[\r\n]/gm, '');
}

console.log("Node: <div>hello world</div>");

var str = removeNode("hello world", "div");

console.log("String returned: " + str);
```

are:

Node match: `<div>hello world</div>`

`removeNode("hello world", "div");` will return:

`hello world`

The function itself will return the `string` within the node.

More info can be found here about [Regular Expressions](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions).
For what it's worth here's a solution done using only jQuery. 

You could do something similar with a server side XML parser

**Data used for search and replace:**

```
  // selector = jQuery selector, final = replacement element
  var tags = [{
      selector: 'emphasis[Type="Italic"]',
      final: '<i>'
    }, {
      selector: 'emphasis[Type="Bold"]',
      final: '<strong>'// note <b> is deprecated
    }, {
      selector: 'emphasis[Type="Underline"]',
      final: '<u>'
    }, {
      selector: 'para',
      final: '<p>'
    }
  ];

```

**Parser:**

```
$(function() {

  // get string to parse
  var str = $('#txtArea').val();
  // inject in temporary div
  var $tempdiv = $('<div>').html(str);
  // loop over all the tags to replace
  $.each(tags, function(_, tag) {
    // loop and replace instances of tags
    $tempdiv.find(tag.selector).replaceWith(function() {
      return $(tag.final).html( $(this).html())
    });
  });
  // get final string from temp div
  var finalString = $tempdiv.html()
  // update textarea
  $('#final').val(finalString );
});

```

`**[DEMO](http://plnkr.co/edit/Er1VWWIpwE9eKZvhsPTh?p=preview)**`