JavaScript searches for a string and returns the search result to the string

  • 2020-05-26 07:48:32
  • OfStack

This article demonstrates how JavaScript searches for strings and returns the search result to the string. Share with you for your reference. The details are as follows:

The javascript operation string with one match method is used to search the string, returning the search string if the specified string is found, or null if not, and match is case sensitive

<!DOCTYPE html>
var str="Hello world!";
document.write(str.match("world") + "<br>");
document.write(str.match("World") + "<br>");
document.write(str.match("worlld") + "<br>");

Return results:


I hope this article has helped you with your javascript programming.

Related articles: