Hi rekha,

The search function uses regular expressions for searching the string in a page.
So '+' means something else(to be precise: "atleast one") in regular expression. To make search() to recognize your '+' as '+' and not something else, you have to escape that character.

You can do like this:
Code:
<script type="text/javascript">

    var str="Javascript";
    document.write(str.search(/C\+\+/));

</script>
In this code, '/' denotes the start and end of regexp and '\' escapes the '+' sign and makes it behave like a character.
SaswatPadhi, shabbir likes this