Question: I have the following code 

```
        <?php
        $doc = new DOMDocument;
        $doc->loadhtml('<html>
                       <head> 
                        <title>bar , this is an example</title> 
                       </head> 
                       <body> 
                       <h1>latest news</h1>
                       foo <strong>bar</strong> 
                      <i>foobar</i>
                       </body>
                       </html>');

        $xpath = new DOMXPath($doc);
        foreach($xpath->query('//*[contains(child::text(),"bar")]') as $e) {
              echo $e->tagName, "\n";
        }

```

Prints

```
       title
       strong
       i

```

this code finds any HTML element that contains the word "bar" and it matches words that has "bar" like "foobar" I want to change the query to match only the word "bar" without any prefix or postfix

I think it can be solved by changing the query to search for every "bar" that has not got a letter after or before or has a space after or before

this code from a past question [here](https://stackoverflow.com/questions/1231606/how-to-figure-out-the-location-of-a-keyword-in-an-html-document) by [VolkerK](https://stackoverflow.com/users/4833/volkerk)

Thanks

Answer: 
I might be wrong, but in Win32 land you don't get mouse move messages when the mouse is at the edge of the screen because, well, the mouse isn't moving. The usual way to get an infinite mouse area is to do the following:

1. Hide the mouse, get exclusive access and record position
2. Centre mouse to window
3. When mouse moves, get delta from centre of screen to current position
4. Centre mouse to window again
5. The next mouse move should have a delta of (0,0), so ignore it
6. Go to 3 until end of mouse move operation
7. Reset position, show the mouse and release exclusive access

If you didn't hide the mouse, then you'd see the mouse moving a small distance and then snapping back to the centre position, which looks nasty.

This method does require a message pump for the mouse move messages so the console application idea probably won't work with this. Can you create a full screen invisible window for grabbing the mouse?
I don't have any direct experience with raw input, which is probably what you need to tap into. [According to MSDN](http://msdn.microsoft.com/en-us/library/bb206183%28VS.85%29.aspx), you have to register the device, then setup your winproc to accept the WM\_INPUT messages and then do your calculations based on the raw data. 

Here's [another relevant link](http://msdn.microsoft.com/en-us/library/ms645543%28VS.85%29.aspx).