-
-
Notifications
You must be signed in to change notification settings - Fork 0
Text.RegexReplace
Rodrigo Celso de Lima Porto edited this page Jan 13, 2026
·
1 revision
Replaces substrings in a text that match a regular expression pattern with a specified replacement string.
Text.RegexReplace(
textToModify as text,
regexPattern as text,
replacer as text,
optional global as logical,
optional caseInsensitive as logical,
optional multiline as logical
) as nullable text-
textToModify: The input text in which to perform the replacements. -
regexPattern: The regular expression pattern to match substrings for replacement. -
replacer: The string to replace matched substrings with. -
global(optional): A logical value indicating whether to replace all occurrences (true) or just the first occurrence (false). Default isfalse. -
caseInsensitive(optional): A logical value indicating whether the regex matching should be case insensitive. Default isfalse. -
multiline(optional): A logical value indicating whether to treat the input text as multiline. Default isfalse.
Returns the modified text with the specified replacements. If no matches are found, returns the original text.
- Uses .NET regular expressions for pattern matching and replacement.
- If
globalistrue, replaces all matches; otherwise, replaces only the first match. - Due to Power Query's JavaScript parser limitations, some advanced regex features like lookbehind '(?<=pattern)' and negative lookbehind '(?<!pattern)' and certain flags (
s,u,v,d,y) are not supported. - Only the flags
g,i,mare available.
Example 1: Replacing text to another one.
Text.RegexReplace("Hello World", "World", "Universe")Result
"Hello Universe"Example 2: Replacing all numbers in text to word "number".
Text.RegexReplace("abc 123 def 456", "\d+", "number", true)Result
"abc number def number"Example 3: Replacing all words at start of a line which start with a "W" and end with a "d" by "Everyone".
Text.RegexReplace("Hello#(lf)World", "^W\w*?d", "Everyone", false, false, true)Result
"Hello#(lf)Everyone"- Binary.Unzip πβοΈ
- DateTime.ToUnixTime πβοΈ
- Decision.EntropyWeights πβοΈ
- Decision.TOPSIS πβοΈ
- List.Correlation πβοΈ
- List.Intercept πβοΈ
- List.Outliers πβοΈ
- List.PopulationStdDev πβοΈ
- List.Primes πβοΈ
- List.Rank πβοΈ
- List.Slope πβοΈ
- List.Variance πβοΈ
- List.WeightedAverage πβοΈ
- Number.FromRoman πβοΈ
- Number.IsInteger πβοΈ
- Number.IsPrime πβοΈ
- Number.ToRoman πβοΈ
- Statistical.NormDist πβοΈ
- Statistical.NormInv πβοΈ
- Table.AddColumnFromList πβοΈ
- Table.CorrelationMatrix πβοΈ
- Table.NormalizeColumnNames πβοΈ
- Table.NormalizeTextColumns πβοΈ
- Table.RemoveBlankColumns πβοΈ
- Table.TransposeCorrectly πβοΈ
- Text.CountChar πβοΈ
- Text.ExtractNumbers πβοΈ
- Text.HtmlToPlainText πβοΈ
- Text.RegexExtract πβοΈ
- Text.RegexReplace πβοΈ
- Text.RegexSplit πβοΈ
- Text.RegexTest πβοΈ
- Text.RemoveAccents πβοΈ
- Text.RemoveDoubleSpaces πβοΈ
- Text.RemoveLetters πβοΈ
- Text.RemoveNumerals πβοΈ
- Text.RemovePunctuations πβοΈ
- Text.RemoveStopwords πβοΈ
- Text.RemoveWeirdChars πβοΈ
- AreArraysEquals πβοΈ
- AutoFillFormulas πβοΈ
- CleanString πβοΈ
- DisableRefreshAll πβοΈ
- EnableRefreshAll πβοΈ
- FileExists πβοΈ
- FileNameIsValid πβοΈ
- GetAllFileNames πβοΈ
- GetLetters πβοΈ
- GetMonthNumberFromName πβοΈ
- GetStringBetween πβοΈ
- GetStringWithSubstringInArray πβοΈ
- GetTableColumnNames πβοΈ
- IsAllTrue πβοΈ
- IsInArray πβοΈ
- ListObjectExists πβοΈ
- PreviousMonthNumber πβοΈ
- RangeHasAnyFormula πβοΈ
- RangeHasConstantValues πβοΈ
- RangeIsHidden πβοΈ
- RangeToHtml πβοΈ
- SendEmail πβοΈ
- SetQueryFormula πβοΈ
- StringContains πβοΈ
- StringEndsWith πβοΈ
- StringStartsWith πβοΈ
- SubstringIsInArray πβοΈ
- Summation πβοΈ
- TableHasQuery πβοΈ
- WorksheetHasListObject πβοΈ