WolframLang: String Replace
Replace by Position Range
StringReplacePart
-
replace string by position range.
StringReplacePart[ "abcdef", "xx", {1,4}] (* "xxef" *)
Replace by String Pattern
StringReplace[ str , findStr -> replaceStr]
-
replace string.
the findStr can be a pattern, represented by Regular Expression or String Expression
StringReplace[ "some dogs" , "dog" -> "cat"] (* "some cats" *)
(* replace letter prefixed digits by x prefix *) StringReplace[ "good g935 m66 z024 m12 g904 q08", RegularExpression["[a-z](\\d+)"] -> "x$1" ] (* good x935 x66 x024 x12 x904 x08 *)
StringReplace[ str , listOfPairs]
-
Replace multiple pairs of strings. Replacement does not depend on previous replacement.
(* replace multiple pairs of strings. replacement does not depend on previous replacement. *) StringReplace["abc", {"a"->"x", "b"->"y", "x"->"H"}] (* xyc *)
WolframLang String
- WolframLang: String
- WolframLang: String Functions
- WolframLang: Get SubString
- WolframLang: Convert String
- WolframLang: Format String
- WolframLang: String Match
- WolframLang: String Replace
- WolframLang: Regular Expression
- WolframLang: String Expression
- WolframLang: StringExpression Pattern Syntax
- WolframLang: RegularExpression vs StringExpression