This article mainly introduces how to search strings in JavaScript and return the search results to strings. it involves the matching method in javascript to operate strings. it has some reference value, for more information about how to search strings in JavaScript, see the following example. Share it with you for your reference. The details are as follows:
The javascript operation string carries a match method for searching strings. if a specified string is found, a search string is returned. if not found, null is returned. The match method is case sensitive.
Script var str = "Hello world! "; Document. write (str. match (" world ") +"
"); Document. write (str. match (" World ") +"
"); Document. write (str. match (" worlld ") +"
"); Document. write (str. match (" world! "); Script
Returned results:
World
Null
Null
World!
I hope this article will help you design javascript programs.