regexReplace specific pattern

Hello KNIME Community,

I hope you’re all doing well. I’m currently working on a project in KNIME where I need to use the regexReplace function to perform some string manipulation. However, I’m encountering some challenges and would greatly appreciate your expertise in helping me resolve this issue.

Input Data Format: I have a dataset containing strings in the following format:

Goal: I want to use the regexReplace function in KNIME to extract the filenames that end with “.pdf” from each string. I also provided “Result” column for the expected results.

Row ID File name Result
1 Abc.html, ab – 2000 .pdf, xy .z.csv ab – 2000 .pdf
2 Ee45.pdf, a z c12.html, 890b v.html Ee45.pdf
3 12.html, 34n y.html, ss.pdf ss.pdf
4 Mn.pdf Mn.pdf
5 ? ?

Could you please provide guidance on the correct regex pattern and usage of the regexReplace function in KNIME to achieve my desired output?

Thank you in advance for your time and assistance.

Best regards,

Suad

I forgot to add If there is no match, it should return an empty “?” value like the last row in the result column.

Thank you again

Hi @Suad_Alshammari

I’m sorry I can’t provide a solution using regex. But your problem can be solved with a Column List Loop, see
specific_pattern.knwf (47.6 KB)


gr. Hans

1 Like

Hi @Suad_Alshammari

Are you explicitly bound to regexReplace? I would go for a Regex Extractor (Regex Extractor — NodePit)

Pattern can be copied from here, the forum butchers it: regex101: build, test, and debug regex

2 Likes

thank you @ArjenEX and @HansS. I found the right expression.

2 Likes

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