Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Get Substring Between Two Words</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var myStr = "The quick brown fox jumps over the lazy dog."; var subStr = myStr.match("quick(.*)lazy"); alert(subStr[1]); }); }); </script> </head> <body> <p>Click the following button to get the substring between the word "quick" and "lazy" from the string "The quick brown fox jumps over the lazy dog."</p> <button type="button">Get Substring</button> </body> </html>