Question: I would like to search any IP Addresses that would exist in the body of mails that is in my inbox on Lotus notes.
I am assuming some regular expression with wildcards should be used when searching.

Thanx in advance for any assistance.

Answer: 
Here is a plain JS solution that does what you want:

**HTML**

```
<div id="test">Chat</div>

```

**JavaScript:**

```
var wordselection = [
{ 'word': "Pomme", "gender": "m" },
{ "word": "Banane", "gender": "f"},
{ "word": "Ananas", "gender": "m" },
{ "word": "Chat", "gender": "f" },
{ "word": "Chien", "gender": "m" },
{ "word": "Poisson", "gender": "f" }

];   

var word = document.getElementById('test').innerHTML;

var item = wordselection.filter(function(el){
  return el.word == word
})[0];

console.log(item && item.gender);

```

It logs undefined if the word in the div is not from the list.

DEMO: <http://jsbin.com/AlOtINE/1/edit>

**EDIT:** If you need to check many such words, you can get better performance by storing them in a map (also known as Object in JavaScript):

```
var wordselection = {
  'Pomme' : 'm',
  'Banane' : 'f',
  'Ananas' : 'm',
  'Chat' : 'f',
  'Chien' : 'm',
  'Poisson' : 'f'
}

```

Then the filtering part is as simple as:

```
console.log(wordselection[word]); // gender or undefined

```

If you get the wordselection from an external source but still want to convert it to the above format you can use this snippet:

```
var optimizedwordselection;
for (var i=0; i<wordselection.length; i++) {
  optimizedwordselection[wordselection.word] = wordselection.gender;
}

```
I don't know your full code structure or actual implementation. However, I would do it either of the 2 ways. There might be many other ways to achieve the solution.

1. Copy the HTML of the DIV element using <http://api.jquery.com/html/> 
in a variable. The HTML will be stored as a string. Search in the
string and see if the "word" exists. If it does or does not, take
appropriate action.
2. Create a temporary Array. Store the key value pairs in that Array. E.g. {"Poisson","F"}. Later when you want to find whether the "word" exists, just search in the Array whether they key exists or not. If KEY exists, then you can always check its value which will be gender.

```
var holder = new Array();

function randomword(){
    var chosen = wordselection[Math.floor(Math.random()*wordselection.length)].word

    if( checkPost(chosen) ){
        document.getElementById("wordinput").innerHTML=chosen;
        holder['chosen'] = gender_variable;
    }
}

function checkPost(word){
    if( holder[word] === undefined ) {
        return null;
    }
    return holder[word];
}

```