Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
and
I've followed, the need to make comparisons between a text string and a pattern, as does the VLOOKUP function, has emerged.
let
matchPatt = (schema, parola) => match(Text.Split(schema, "*"), parola),
match
= (pattern, word) => if List.Count(pattern) = 1 and
(pattern{0} = "" or (List.Count(pattern) = 1 and pattern{0} <> "" and Text.StartsWith(Text.Reverse(word), Text.Reverse(pattern{0}))
)
) then
"match"
else if List.Count(pattern) = 1 and (pattern{0} <> "" and pattern{0} <> word) then
"not match"
else if Text.StartsWith(word, pattern{0}) then
let
tailPattern = List.Skip(pattern),
tailWord =
if (List.IsEmpty(tailPattern) or tailPattern{0} = "" or Text.PositionOf(word, tailPattern{0}) = - 1 ) then
Text.Range(word, Text.Length(pattern{0}))
else
Text.Range(
Text.Range(word, Text.Length(pattern{0})),
Text.PositionOf(Text.Range(word, Text.Length(pattern{0})), tailPattern{0})
)
in
@match(tailPattern, tailWord)
else
"not match"
in
matchPatt
Hi @Anonymous ,
So, what is your purpose for posting this post? 🤔
Best Regards,
Icey
Hi @Icey
the purpose of the post is what I wrote in the message and which I report here.
<<It was not easy for me to find a solution that was suitable for all the cases that came to mind from time to time and I am still not sure that it is very "robust".
I'd like to, if someone wants to try it out and point out situations where it doesn't do what it was meant for.>>
this fixes a bug and does some toilet
let
matchPatt = (schema, parola) => match(Text.Split(schema, "*"), parola),
match
= (pattern, word) => if List.Count(pattern) = 1
then
if (pattern{0} = "" or Text.EndsWith(word, pattern{0}) )
then
"match"
else
"not match"
else
if Text.StartsWith(word, pattern{0}) then
let
tailPattern = List.Skip(pattern),
tailWord = [tr=Text.Range(word, Text.Length(pattern{0})),
trw= try Text.Range(tr, Text.PositionOf(tr, tailPattern{0})) otherwise tr]
[trw]
in
(tailPattern, tailWord)
else
"not match"
in
matchPatt
let
matchPatt = (schema, parola) => match(Text.Split(schema, "*"), parola),
match
= (pattern, word) => if List.Count(pattern) = 1
then
if (pattern{0} = "" or Text.EndsWith(word, pattern{0}) )
then
"match"
else
"not match"
else
if Text.StartsWith(word, pattern{0})
then
let
tailPattern = List.Skip(pattern),
tr=Text.Range(word, Text.Length(pattern{0})),
pos= Text.PositionOf(tr, tailPattern{0}),
tailWord = try Text.Range(tr, pos) otherwise tr
in
@match(tailPattern, tailWord)
else
"not match"
in
matchPatt
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.