Just don't anchor your pattern:

/Test/

The above regex will check for the literal string "Test" being found somewhere within it.

Answer from Platinum Azure on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › match
String.prototype.match() - JavaScript | MDN
The input property is the original string that was parsed. The following example demonstrates the use of the global flag and ignore-case flag with match(). All letters A through E and a through e are returned, each its own element in the array. ... const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; const regexp = /[a-e]/gi; const matches = str.match(regexp); console.log(matches); // ['A', 'B', 'C', 'D', 'E', 'a', 'b', 'c', 'd', 'e']
🌐
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Regular_expressions
Regular expressions - JavaScript | MDN
To include a flag with the regular expression, use this syntax: js · const re = /pattern/flags; or · js · const re = new RegExp("pattern", "flags"); Note that the flags are an integral part of a regular expression. They cannot be added or removed later. For example, re = /\w+\s/g creates a regular expression that looks for one or more characters followed by a space, and it looks for this combination throughout the string.
🌐
W3Schools
w3schools.com › jsref › jsref_match.asp
W3Schools.com
break class const continue debugger do...while for for...in for...of function if...else let return switch throw try...catch var while JS Strings · at() charAt() charCodeAt() codePointAt() concat() constructor endsWith() fromCharCode() includes() indexOf() isWellFormed() lastIndexOf() length localeCompare() match() matchAll() padEnd() padStart() prototype repeat() replace() replaceAll() search() slice() split() startsWith() substr() substring() toLocaleLowerCase() toLocaleUpperCase() toLowerCase() toString() toUpperCase() toWellFormed() trim() trimEnd() trimStart() valueOf() JS Typed Arrays ·
🌐
SitePoint
sitepoint.com › javascript
Is there a way to use RegEx with the Javascript includes() function? - JavaScript - SitePoint Forums | Web Development & Design Community
May 5, 2018 - var locations = [ 'Philippines', 'Singapore', 'China', 'New York' ]; var results = locations.filter(function(location) { return location.includes('e'); }); console.log(results); What I am trying to do with t…
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › includes
String.prototype.includes() - JavaScript | MDN
const sentence = "The quick brown fox jumps over the lazy dog."; const word = "fox"; console.log( `The word "${word}" ${ sentence.includes(word) ? "is" : "is not" } in the sentence`, ); // Expected output: "The word "fox" is in the sentence" ... A string to be searched for within str. Cannot be a regex.
🌐
ReqBin
reqbin.com › code › javascript › vy4txenr › javascript-string-contains-example
How do I check if a string contains a substring in JavaScript?
January 24, 2023 - To check if a string contains a substring in JavaScript, use the string.includes(term, start) method, which checks if the string contains the substring. The first parameter is the string to search for, and the second optional parameter specifies ...
🌐
JavaScript.info
javascript.info › tutorial › regular expressions
Methods of RegExp and String
The method str.match(regexp) finds matches for regexp in the string str.
Find elsewhere
🌐
Honeybadger
honeybadger.io › blog › javascript-regular-expressions
The ultimate JavaScript regex guide - Honeybadger Developer Blog
May 9, 2025 - The code above creates a pattern that matches phone numbers, a string that includes two phone numbers in the format specified by the pattern, and a while loop that iterates over all matches found by the exec method and logs each match to the console. The code above will return the following: The search method typically works on all strings, but you can also use it to test regex patterns:
🌐
Stack Overflow
stackoverflow.com › questions › 5296268 › fastest-way-to-check-a-string-contain-another-substring-in-javascript
regex - Fastest way to check a string contain another substring in JavaScript? - Stack Overflow
I'm working with a performance issue on JavaScript. So I just want to ask: what is the fastest way to check whether a string contains another substring (I just need the boolean value)? Could you pl...
🌐
SitePoint
sitepoint.com › blog › javascript › quick tip: testing if a string matches a regex in javascript
Quick Tip: Testing if a String Matches a Regex in JavaScript — SitePoint
November 6, 2024 - When you’re testing if a string ... expressions is a better option. JavaScript regex matching allows you to check if a string contains a specific pattern, substring, or types of characters....
🌐
Built In
builtin.com › software-engineering-perspectives › javascript-regex
A Guide to JavaScript Regular Expressions (RegEx) | Built In
Since forward slashes are used to enclose patterns in the above example, you have to escape the forward slash ( / ) with a backslash ( \ ) if you want to use it as a part of the regex. There are two main methods for testing regular expressions. This method is used to test whether a match has been found or not. It accepts a string which we have to test against a regular expression, and it returns true or false depending upon if the match is found or not.
🌐
freeCodeCamp
freecodecamp.org › news › javascript-regex-match-example-how-to-use-the-js-replace-method-on-a-string
JavaScript Regex Match Example – How to Use JS Replace on a String
January 4, 2021 - In this tutorial, we'll go over ... included JS methods · According to MDN, regular expressions are "patterns used to match character combinations in strings". These patterns can sometimes include special characters (*, +), assertions (\W, ^), groups and ranges ((abc), [123]), and other things that make regex so powerful ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › RegExp › test
RegExp.prototype.test() - JavaScript | MDN
This example tests if "hello" is contained at the very beginning of a string, returning a boolean result. ... function testInput(re, str) { const midString = re.test(str) ? "contains" : "does not contain"; console.log(`${str} ${midString} ${re.source}`); } When a regex has the global flag set, test() will advance the lastIndex of the regex.
🌐
Eloquent JavaScript
eloquentjavascript.net › 09_regexp.html
Regular Expressions
In some cases you may not know the exact pattern you need to match against when you are writing your code. Say you want to test for the user’s name in a piece of text. You can build up a string and use the RegExp constructor on that.
🌐
YouTube
youtube.com › shorts › cYvBdQFc8F4
How to use regex to check if a javascript string contains a pattern #shorts - YouTube
Regex is very useful, be sure to take time to learn it.My VSCode Extensions:- theme: material community high contrast- fonts: Menlo, Monaco, 'Courier New', m...
Published   September 12, 2022
🌐
CodingNomads
codingnomads.com › match-string-javascript
JavaScript String Matching
Explicitly creating RegExp objects does give you the opportunity to add things like flags. With your regular expression in hand, you can now use it to find matches in the text. First off, you may want to find out if the text contains an e-mail at all. First up, you'll see if a string contains a substring using the .search() method.
🌐
Medium
medium.com › nerd-for-tech › basics-of-javascript-string-match-method-ce47295bfd97
Basics of Javascript · String · match() (method) | by Jakub Korch | Nerd For Tech | Medium
June 9, 2021 - That's...", // length: 0 // ]regExp.exec(str) // [ // "ain", // groups: undefined, // index: 5, // input: "The main bulk of rain will fall in SPAIN. That's...", // length: 0 // ](str.match(regExp))[0] // ain · First case uses regular expressions searching for the string “ain” with the additional flag “g” which specifies that we want to find all the matches.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › matchAll
String.prototype.matchAll() - JavaScript | MDN
July 10, 2025 - The matchAll() method of String values returns an iterator of all results matching this string against a regular expression, including capturing groups. const regexp = /t(e)(st(\d?))/g; const str = "test1test2"; const array = [...str.matchAll(regexp)]; console.log(array[0]); // Expected output: Array ["test1", "e", "st1", "1"] console.log(array[1]); // Expected output: Array ["test2", "e", "st2", "2"] js ·