Help Needed: Regular Expression to Remove Number Rows and Hyphenated Number Rows

Hello KNIME Community,

I am currently working on a text clustering project and encountering an issue with my output. The output includes rows that contain only numbers and rows where numbers are connected by hyphens. I want to remove these rows but haven’t found an effective regular expression to do so. Here are the details:

  1. Current Output:
  • Rows with only numbers (e.g., 123)
  • Rows with numbers connected by hyphens (e.g., 123-456)
  1. Goal:
  • Remove rows that contain only numbers.
  • Remove rows where numbers are connected by hyphens.

Could anyone suggest a regular expression or an alternative approach to achieve this?

Thank you for your assistance!

Best regards,
Dharma

Hello!

You mentioned trying regex for your problem, will you share what have you attempted so that the others will be able to point out what you did wrong?

This sounds like a simple task to do. But it would be helpful to also see how your data looks like to assess its complexity. You can either upload your workflow, or simply paste several examples of rows here:

2 Likes

Hello @dharma and welcome to the KNIME Community!

You can test a ‘Rule-based Row Filter’ node with the following code:

// 
$row_id$ MATCHES "[\d-]+" => TRUE
TRUE => FALSE

Excluding TRUE matches.

BR

2 Likes

Thank you very much for your reply. I have solved my problem with small modification of your advice !! This is my first consultation in KNIME forum and feel extremely powerful.

1 Like

Thank you for your prompt reply. I have managed to solve my problem by the other suggestion. From next time, I will explain my situiation as detail as possible. Thank you for your advice !!

Hi @dharma , welcome to the KNIME forum.

I’m glad to hear you got to a solution.

If @gonhaddock’s suggestion was key to you solving your question, please remember to mark his answer as the solution, so that others can see this has been resolved, and if people have a similar question in future they can quickly get to the answer.

It also gives well deserved kudos to the contributor. :wink:


3 Likes

I have not known the system of "Solution " button you mentioned. Now I understand the rule of communitThaknk you for your repeated kind advice !! !!

3 Likes