Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

replace

Cette page est en cours de traduction, son contenu peut donc être incomplet ou contenir des parties en anglais. N'hésitez pas à participer à sa traduction à partir de EXSLT:regexp:replace


regexp:replace() replaces the portions of a string that match a given regular expression with the contents of another string.

Syntax

regexp:replace(originalString, regExpString, flagsString, replaceString)

Arguments

originalString
The string perform a search-and-replace operation upon.
regExpString
The JavaScript style regular expression to evaluate.
flagsString
An string containing character flags.

The character flags are:

g - Global replace
If this flag is specified, all occurrences of the regular expression within the originalString are replaced. Otherwise only the first occurrence is replaced.
i - Case insensitive match
If this flag is specified, the match is performed in a case insensitive fashion.
replaceString
The string with which the matched substrings are to be replaced.

Returns

The revised version of the string.

Defined

EXSLT - REGEXP:REPLACE

Gecko support

Supported in Gecko 1.9 and later.

Étiquettes et contributeurs liés au document

Étiquettes : 
 Contributeurs à cette page : sylvain.spinelli, Mgjbot, Fredchat
 Dernière mise à jour par : sylvain.spinelli,