-
-
Notifications
You must be signed in to change notification settings - Fork 0
Text.RegexExtract
Rodrigo Celso de Lima Porto edited this page Jan 13, 2026
·
1 revision
Extracts a substring from a text by using a regular expression pattern.
Text.RegexExtract(
textToExtract as text,
regexPattern as text,
optional global as logical,
optional caseInsensitive as logical,
optional multiline as logical
) as any-
textToExtract: The input text from which to extract the substring. -
regexPattern: The regular expression pattern to use for extraction. -
global(optional): A logical value indicating whether to extract all matches (true) or just the first match (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 extracted substring(s) based on the regex pattern. If global is true, returns a list of all matches; otherwise, returns the first match or null if no match is found.
- Uses .NET regular expressions for pattern matching.
- If
globalistrue, returns a list of all matches; otherwise, returns the first match ornullif no match is found. - 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: Extract patterns which start with "W" and end with "d".
Text.RegexExtract("Hello World", "W.*d")Result
"World"Example 2: Extracts all numbers from a text by activating the global flag.
Text.RegexExtract("abc 123 def 456", "\d+", true)Result
{"123", "456"}Example 3: By activating the multiline flag, the character "^" and "$" comes to mean, respectively, "start of line" and "end of line" instead of "start of text" and "end of text".
Text.RegexExtract("Hello#(lf)World", "^W.*?d", false, false, true)Result
"World"- 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 πβοΈ