Sv Replace

From GECK
Jump to: navigation, search


A function added by the New Vegas Script Extender.

Description

Replaces occurrences of an old string with a new string within a string variable. Both the old and new text is passed in a single format string argument, separated by a pipe character as in "Old|New" (when calling from the console, use '@' in place of the pipe character).

By default this function replaces all occurrence in the entire string and is case insensitive. Optionally, a range may be specified by start character and length thereafter, a case sensitive flag and a maximum occurrences to replace may be provided.

Note that this function modifies a string_var in place, and returns the count of number of replacements as an int, not a new string.

Syntax

[help]
(NumReplaced:int) Sv_Replace Old|New:string Formatting Source:string_var StartPos:int SearchLen:int CaseSensitive:bool MaxReplacements:int 

Example

string_var my_string

let my_string := "the cat is great"

Sv_Replace "great|terrible", my_string

; my_string is now: "the cat is terrible"

See Also