```
function fun() {
    var temp = document.getElementById('DIV2').innerHTML;
    var str = temp;
    var res = str.replace(/(\s(\S*m)\s)/gi, ' <span class="red">$1</span> '); // 0.5 -- 1m -- etc 
    var res2 = res.replace(/\s(\S*metre)\s/gi, '<span class="red">$1</span> '); // 1meter 2meter
    var res3 = res.replace(/\s(\S\s*metre)\s/gi, '<span class="red">$1</span> '); // 1 meter 2 meter
    document.body.innerHTML = res3;
}

```

```
<body>
    <div id="text">
    The Basic High Speed HDMI 0.5m Cables with Ethernet are 0.5m suitable for use with HDMI.
    Home Theater, 1m Games Consoles (including Nintendo Wii U), 1m Blu-rays, Cable or Satelite 1m boxes and Projectors. 
    HDMI Cables provides the most reliable digital signal transfer and the purest picture. 
    </div>
</html>

```

The above code matches `"0.5m, 1m, 1 metre"` etc. in a string but it searches for all the occurrence in a line I wanted to make stop at the first occurrence of the pattern and continue at the next line.

Can anybody help?