diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:52 -0500 |
commit | 074785cea106179cb3305637055ab0a009ca74f2 (patch) | |
tree | e6ae371cccd642aa2b67f39752a2cdf1fd4eb040 /files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html | |
parent | da78a9e329e272dedb2400b79a3bdeebff387d47 (diff) | |
download | translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.gz translated-content-074785cea106179cb3305637055ab0a009ca74f2.tar.bz2 translated-content-074785cea106179cb3305637055ab0a009ca74f2.zip |
initial commit
Diffstat (limited to 'files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html')
-rw-r--r-- | files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html b/files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html new file mode 100644 index 0000000000..f69a22537d --- /dev/null +++ b/files/pt-br/web/javascript/reference/global_objects/symbol/replace/index.html @@ -0,0 +1,60 @@ +--- +title: Symbol.replace +slug: Web/JavaScript/Reference/Global_Objects/Symbol/replace +translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/replace +--- +<div>{{JSRef}}</div> + +<p>O símbolo <code><strong>Symbol.replace</strong></code> é conhecido por especificar o método que substitui as substrings conrrespondentes de uma string. Essa função é chamada pelo método {{jsxref("String.prototype.replace()")}}.</p> + +<p>Para mais informações, veja {{jsxref("RegExp.@@replace", "RegExp.prototype[@@replace]()")}} e {{jsxref("String.prototype.replace()")}}.</p> + +<div>{{EmbedInteractiveExample("pages/js/symbol-replace.html")}}</div> + + + +<div>{{js_property_attributes(0,0,0)}}</div> + +<h2 id="Exemplos">Exemplos</h2> + +<h3 id="Usando_Symbol.replace">Usando Symbol.replace</h3> + +<pre class="brush: js notranslate">class CustomReplacer { + constructor(value) { + this.value = value; + } + [Symbol.replace](string) { + return string.replace(this.value, '#!@?'); + } +} + +console.log('football'.replace(new CustomReplacer('foo'))); +// resultado esperado: "#!@?tball"</pre> + +<h2 id="Especificações">Especificações</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Especificação</th> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-symbol.replace', 'Symbol.replace')}}</td> + </tr> + </tbody> +</table> + +<h2 id="Compatibilidade_de_navegador">Compatibilidade de navegador</h2> + + + +<p>{{Compat("javascript.builtins.Symbol.replace")}}</p> + +<h2 id="Veja_também">Veja também</h2> + +<ul> + <li>{{jsxref("Symbol.match")}}</li> + <li>{{jsxref("Symbol.search")}}</li> + <li>{{jsxref("Symbol.split")}}</li> + <li>{{jsxref("RegExp.@@replace", "RegExp.prototype[@@replace]()")}}</li> +</ul> |