10 examples of 'find string in jquery' in JavaScript

Every line of 'find string in jquery' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
1export function searchAndReplace(str, find, replace) {
2 return str.split(find).join(replace)
3}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

115function findText(row, search){
116 var iter = document.createNodeIterator(row, NodeFilter.SHOW_TEXT, null);
117
118 while (n = iter.nextNode()){
119 var elementText = n.nodeValue;
120 if(elementText == undefined)
121 continue;
122 if(elementText.toLowerCase().indexOf(search) != -1
123 // check that it's not decoration
124 && acceptTextForSearch(n)){
125 iter.detach();
126 return true;
127 }
128 }
129 iter.detach();
130 return false;
131}
112function findAll(str: string, toFind: string): number[] {
113 var matches = [];
114 var i = str.indexOf(toFind);
115 while (i !== -1) {
116 matches.push(i);
117 i = str.indexOf(toFind, i + toFind.length);
118 }
119 return matches;
120};
62function replaceString(pString,pSearch,pReplace)
63// replaces in the string "pString" multiple substrings "pSearch" by "pReplace"
64{
65 //alert("cstring.js - replaceString() "+pString);
66 if (!pString) {
67 alert("replaceString()-Call - pString not defined!");
68 } else if (pString != '') {
69 {
70 //alert("cstring.js - replaceString() "+pString);
71 var vHelpString = '';
72 var vN = pString.indexOf(pSearch);
73 var vReturnString = '';
74 while (vN >= 0)
75 {
76 if (vN > 0)
77 vReturnString += pString.substring(0, vN);
78 vReturnString += pReplace;
79 if (vN + pSearch.length < pString.length) {
80 pString = pString.substring(vN+pSearch.length, pString.length);
81 } else {
82 pString = ''
83 }
84 vN = pString.indexOf(pSearch);
85 };
86 };
87 return vReturnString + pString;
88 }
89
90};
6function getString(data, key) {
7 var str = data[key] || "";
8 return str.replace(/"/g, "");
9}
127static findPropertyFromString(str, key)
128{
129 let property = key + "=";
130 var index = str.indexOf('?');
131 str = str.substring(index + 1);
132
133 var list = str.split('&');
134
135 for (var i = 0; i < list.length; i++)
136 {
137 if (list[i].search(property) == 0)
138 {
139 return list[i].replace(property, "");
140 }
141 }
142 return null;
143}
10function findValue(html, regexp) {
11 var r = new RegExp(regexp);
12 var matches=r.exec(html);
13 if(matches==null) return null;
14 return matches[1];
15}
16function findString(stringToSearch, uint8Array) {
17 const result = [];
18 const searchString = stringToSearch
19 .split('')
20 .map((char) => char.charCodeAt(0));
21
22 const maxIndex = uint8Array.length - stringToSearch.length;
23 let index = -1;
24 for (const char of uint8Array) {
25 index++;
26 if (index > maxIndex) {
27 return result;
28 }
29 if (char === searchString[0]) {
30 if (_findArray(searchString, index, uint8Array)) {
31 result.push(index);
32 if (result.length > MAX_ELEMENTS_TO_SEARCH) {
33 return result;
34 }
35 }
36 }
37 }
38 return result;
39}
13function findJS(html) {
14 var doc = Slowparse.HTML(document, html).document;
15 return TreeInspectors.findJS(doc);
16}
295function replaceMatchesInString (matches, string, replace) {
296 var offset = 0;
297
298 if (!matches) {
299 return string;
300 }
301
302 for (var i = 0; i < matches.length; i++) {
303 var match = matches[i],
304 replacement = String(replace(string.substr(match.index + offset + match.head.length, match.length - match.head.length - match.tail.length), match.head, match.tail));
305
306 string = string.substr(0, match.index + offset) + replacement + string.substr(match.index + offset + match.length, (string.length) - (match.index + offset + match.length));
307
308 offset += replacement.length - match.length;
309 }
310
311 return string;
312}

Related snippets