Matches in text string

Hello, good afternoon, is there a node or formula to buy two columns and indicate the matches in words. example.

Thank you.

Hi @Gfranco2021

I created this wf matches_text_in_string.knwf (66.6 KB).
Somethings tells me it should be done with less nodes. But anyway see if this helps you out.


gr. hans

4 Likes

Excellent, thank you very much HansS.

1 Like

Hello @Gfranco2021,

I have designed a small workflow to achieve the desired result. Please refer to the attached image of the workflow. Additionally, configure the Java snippet node with the provided code.

Screenshot 2024-02-16 112605

"Set set1 = new HashSet<>();
Set set2 = new HashSet<>();
Set intersection = new HashSet<>();

String words1 = c_CAMPO1.split(" “);
String words2 = c_CAMPO2.split(” ");

for (String word : words1) {
set1.add(word);
}

for (String word : words2) {
set2.add(word);
}

intersection.addAll(set1);
intersection.retainAll(set2);

String data = intersection.toArray(new String[0]);
out_new=String.join(" ", data); "

Result:

Screenshot 2024-02-16 113057

Very well, thank you very much.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.