WLJS LogoWLJS Notebook

StringReplaceList

StringReplaceList["string", s -> sp] gives a list of the strings obtained by replacing each individual occurrence of substrings in "string" matching the string expressions.

  • StringReplaceList["string", {s1 -> sp1, s2 -> sp2, ...}] replaces multiple patterns.
  • StringReplaceList["string", srules, n] gives a list of the first n results obtained.
  • StringReplaceList[{s1, s2, ...}, srules] gives the list of results for each of the si.

Examples

List all possible single replacements:

StringReplaceList["abab", "a" -> "X"]

Replace with multiple patterns:

StringReplaceList["abc", {"a" -> "1", "b" -> "2"}]

Please visit the official Wolfram Language Reference for more details.

On this page