Chapter 15: JavaScript String Object </body> </html>
Your results are shown in Figure 15.3.
Figure 15.3
The following example demonstrates how to search for a specified value within a string. Your results are shown in Figure 15.4.
Try it yourself >> <html> <body> <script type="text/javascript"> var str="Hello world!"; document.write(str.match("world") + "<br />"); document.write(str.match("World") + "<br />"); document.write(str.match("worlld") + "<br />"); document.write(str.match("world!")); </script> </body> </html>
Figure 15.4
The following example shows how to replace a specified value with another value in a string. Your results are shown in Figure 15.5.
85