Enable Regex to increase the power of powerquery. Some function such as split column and extract are good but could be great if custom regex could be used to pattern match more effectively.
zack-c
5 months agoRegular Visitor
When dealing with messy data, it's often paramount to do some text transforms to clean it up a little. I end up writing a lot of regex and just having ChatGPT translate it into Power Query steps/functions because manually transforming text is such a pain in Power Query without regex. It's very quick for me to write regex due to how close the final syntax usually is to the text I'm matching.
For context, a simple regex-based prefix matcher like this:
^[A-Z]{3}-\d{4}\s*(?=\D)
Translates into a Power Query function along the lines of:
(text as nullable text) as nullable text =>
let
t = text,
Prefix = if t <> null and Text.Length(t) >= 8
then Text.Start(t, 8)
else "",
ValidPrefix =
Text.Length(Prefix) = 8 and
Text.Middle(Prefix, 3, 1) = "-" and
// First 3 uppercase letters
List.AllTrue(
List.Transform(
Text.ToList(Text.Start(Prefix, 3)),
each Character.ToNumber(_) >= 65 and Character.ToNumber(_) <= 90
)
) and
// Last 4 digits
List.AllTrue(
List.Transform(
Text.ToList(Text.End(Prefix, 4)),
each Character.ToNumber(_) >= 48 and Character.ToNumber(_) <= 57
)
),
AfterPrefix =
if ValidPrefix
then Text.Range(t, 8)
else t,
TrimmedAfter =
if ValidPrefix
then Text.TrimStart(AfterPrefix)
else t,
// Lookahead equivalent: next char must be non-digit (or absent)
NextCharValid =
Text.Length(AfterPrefix) = 0 or
not List.Contains({"0".."9"}, Text.Start(TrimmedAfter, 1)),
Result =
if ValidPrefix and NextCharValid
then TrimmedAfter
else t
in
Result
Recent ideas
Change the owner of the content of the created lakehouse
Since there is a problem with operation when the account of the owner of the created lakehouse content is closed, I would like to add the function to change the function of the ownerv-isakaguchi11 hour agoMicrosoft EmployeeCompleted4.1KViews115likes7CommentsRestore "no-reply" option for Power BI Subscriptions
Please add a setting in the Power BI Subscription pane to choose the sender identity. With the recent update the platform forces emails to route through the subscription owner's personal Exchange On...LenaFid2 hours agoNew MemberNew63Views10likes3CommentsAllow Subscriptions to send from "no-reply" again
Please add a setting in the Power BI Subscription pane to choose the sender identity. Currently, the platform forces emails to route through the subscription owner's personal Exchange Online mailbox...LenaFid2 hours agoNew MemberNew36Views6likes3Comments