Format: Replace: Diferență între versiuni
De la alegeri.md
Oleg (Discuție | contribuții) (Pagină nouă: {{<includeonly>safesubst:</includeonly>#invoke:String|replace|source={{{1}}}|{{{2}}}|{{{3}}}|plain={{{plain|true}}}|count={{{count|}}}}}) |
Oleg (Discuție | contribuții) |
||
Linia 1: | Linia 1: | ||
− | {{<includeonly>safesubst:</includeonly>#invoke:String|replace|source={{{1}}}|{{{2}}}|{{{3}}}|plain={{{plain|true}}}|count={{{count|}}}}} | + | {{<includeonly>safesubst:</includeonly>#invoke:String|replace|source={{{1}}}|{{{2}}}|{{{3}}}|plain={{{plain|true}}}|count={{{count|}}}}}<noinclude> |
+ | ===Usage=== | ||
+ | <code><nowiki>{{replace|string|target|replacement|count=n}}</nowiki></code> | ||
+ | |||
+ | Returns ''string'' with the first ''n'' occurrences of ''target'' replaced with ''replacement''. Omitting <code>count</code> will replace all occurrences. Space counts as a character if placed in any of the first three parameters. | ||
+ | |||
+ | ===Examples=== | ||
+ | * <code><nowiki>{{replace|One two two three two four twotwo five|two|NINE}}</nowiki></code> → {{replace|One two two three two four twotwo five|two|NINE}} | ||
+ | * <code><nowiki>{{replace|One two two three two four twotwo five|two|NINE|count=2}}</nowiki></code> → {{replace|One two two three two four twotwo five|two|NINE|count=2}} | ||
+ | * <code><nowiki>{{replace|foo_bar|_| }}</nowiki></code> → {{replace|foo_bar|_| }} | ||
+ | ====Space==== | ||
+ | * <code><nowiki>{{replace|One-two two-three two-four twotwo-five|-|—}}</nowiki></code> → {{replace|One-two two-three two-four twotwo-five|-|—}} | ||
+ | * <code><nowiki>{{replace|One-two two-three two-four twotwo-five|- |—}}</nowiki></code> → {{replace|One-two two-three two-four twotwo-five|- |—}}</noinclude> |
Versiunea curentă din 10 noiembrie 2021 00:25
{{{1}}}
Usage
{{replace|string|target|replacement|count=n}}
Returns string with the first n occurrences of target replaced with replacement. Omitting count
will replace all occurrences. Space counts as a character if placed in any of the first three parameters.
Examples
{{replace|One two two three two four twotwo five|two|NINE}}
→ One NINE NINE three NINE four NINENINE five{{replace|One two two three two four twotwo five|two|NINE|count=2}}
→ One NINE NINE three two four twotwo five{{replace|foo_bar|_| }}
→ foo bar
Space
{{replace|One-two two-three two-four twotwo-five|-|—}}
→ One—two two—three two—four twotwo—five{{replace|One-two two-three two-four twotwo-five|- |—}}
→ One-two two-three two-four twotwo-five