From de5c456ebded0e038adbf23db34cc290c8829180 Mon Sep 17 00:00:00 2001 From: Florian Merz Date: Thu, 11 Feb 2021 14:49:24 +0100 Subject: unslug pl: move --- .../global_objects/string/search/index.html | 49 ++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 files/pl/web/javascript/reference/global_objects/string/search/index.html (limited to 'files/pl/web/javascript/reference/global_objects/string/search') diff --git a/files/pl/web/javascript/reference/global_objects/string/search/index.html b/files/pl/web/javascript/reference/global_objects/string/search/index.html new file mode 100644 index 0000000000..29b9d8e8fb --- /dev/null +++ b/files/pl/web/javascript/reference/global_objects/string/search/index.html @@ -0,0 +1,49 @@ +--- +title: String.prototype.search() +slug: Web/JavaScript/Referencje/Obiekty/String/search +tags: + - JavaScript + - Method + - Prototype + - String +translation_of: Web/JavaScript/Reference/Global_Objects/String/search +--- +

{{JSRef}}

+ +

Podsumowanie

+ +

Wykonuje przeszukanie dla dopasowanych wyrażeń regularnych i tego obiektu {{jsxref("String")}}.

+ +

Składnia

+ +
str.search(regexp)
+ +

Parametry

+ +
+
regexp 
+
Nazwa wyrażenia regularnego. Może być to nazwa zmiennej lub literał.
+
+ +

Opis

+ +

Jeśli sukces, rezultat przeszukania indeksu wyrażenia regularnego wewnątrz łańcucha znaków. Inaczej zwróci -1.

+ +

Kiedy chcesz wiedzieć gdzie jest znaleziony wzorzec w łańcuchu znaków zastosuj search() (podobne do wyrażenia regularnego metody {{jsxref("RegExp.prototype.test()", "test()")}}); aby uzyskać więcej informacji (lecz wolniej wykonywanie) zastosuj {{jsxref("String.prototype.match()", "match()")}} (podobne do wyrażenia regularnego metody {{jsxref("RegExp.prototype.exec()", "exec()")}} method).

+ +

Przykłady

+ + + +

Następujący przykład drukuje wiadomość, która zależy od sukcesu testu.

+ +
function testinput(re, str){
+   var midstring;
+   if (str.search(re) != -1) {
+      midstring = " contains ";
+   } else {
+      midstring = " does not contain ";
+   }
+   console.log (str + midstring + re.source);
+}
+
-- cgit v1.2.3-54-g00ecf