Shoji
(Shoji Yamada)
February 14, 2023, 1:33pm
1
Hello I’m using word boundary “\b” to search for specific word. My problem occurs when I’m extracting something with same name in the same column.
For example, I have this person address: Abad Avenue Tondo Manila
The output I’m getting is this:
Expected output:
I’m getting “Manila” in the last column because there’s also “Manilla” in the “Barangay” column but it belongs to another place.
Here, I provided the xaml file
Main.xaml (33.6 KB)
How do I fix this?
Yoichi
(Yoichi)
February 14, 2023, 1:57pm
2
Hi,
How about the following single regex instead of 3 regex.ismatch?
dtRef.AsEnumerable.Where(Function(x) System.Text.RegularExpressions.Regex.IsMatch(CurrentRowData("Address").ToString.ToLower, "\b"+x("Province").ToString.ToLower+"\b.*\b"+x("Municipality").ToString.ToLower+"\b.*\b"+x("Barangay").ToString.ToLower+"\b")).Count > 0
It might be necessary to change order of Province, Municipality and Barangay.
Regards,
Shoji
(Shoji Yamada)
February 14, 2023, 3:10pm
3
It’s the same result, do I need to put that in all my if condition?
Yoichi
(Yoichi)
February 14, 2023, 11:58pm
4
Hi,
Can you share input data and expected output as file? It’s no problem if dummy data.
Regards,
Shoji
(Shoji Yamada)
February 15, 2023, 1:53pm
5
Hello, sorry for the late reply
Here’s the file containing the output I got and the expected output:
address.xlsx (21.7 KB)
Here’s also the list of the areas:
area.xlsx (842.9 KB)
Thank you!
Shoji
(Shoji Yamada)
February 16, 2023, 2:07pm
6
Hello, I just want to let you know that I already fixed it using your solution. My question is, what does this “\b.*\b” do? This help me with the problem. Thank you!
1 Like
Yoichi
(Yoichi)
February 17, 2023, 12:14am
7
Hi,
\b
means word boundary. For example, Can you check the following sample? The former matches is
in This
. However the latter doesn’t match it because \b doesn’t match word boundary.
In this quick reference, learn to use regular expression patterns to match input text. A pattern has one or more character literals, operators, or constructs.
Regards,
1 Like
system
(system)
Closed
February 20, 2023, 12:15am
8
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.