regexReplace in String Manipulation KNIME [英] regexReplace in String Manipulation KNIME

查看:187
本文介绍了regexReplace in String Manipulation KNIME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用KNIME(v3.2.1)删除所有以非数字字符开头的单元格的内容.我有不同的想法,但无济于事.

I'm trying to remove the content of all cells that start with a character that is not a number using KNIME (v3.2.1). I have different ideas but nothing works.

1)字符串操作节点:regexReplace(§column§,"^[^0-9].*","")

1) String Manipulation Node: regexReplace(§column§,"^[^0-9].*","")

单元格包含多行,但是此方法仅删除了第一行.

The cells contain multiple lines, however only the first line is removed by this approach.

2)字符串操作节点:regexMatcher($casrn_new$,"^[^0-9].*"),后跟规则引擎节点"以删除所有为"TRUE"的列.

2) String Manipulation Node: regexMatcher($casrn_new$,"^[^0-9].*") followed by Rule Engine Node to remove all columns that are "TRUE".

即使对于应为"True"的列,regexMatcher也会给我"False".

The regexMatcher gives me "False" even for columns that should be "True" though.

3)字符串替换节点:我将表达式^[^0-9].*插入到模式"列中,并选择替换整个字符串",但是该节点无法识别正则表达式,因此不会替换任何内容.

3) String Replacer Node: I inserted the expression ^[^0-9].* into the Pattern column and selected "Replace whole String" but the regex is not recognised by that node so nothing gets replaced.

有人对这些方法有解决方案吗,还是知道另一个可以完成这项工作的节点?非常感谢您的帮助!

Does anyone have a solution for any of those approaches or knows another Node that might do the job? Help is much appreciated!

推荐答案

我将使用您的第一个解决方案,因为它已经起作用,所以您只需扩展正则表达式以包括换行符即可.我会尝试这样的事情:

I would go with your first solution, since it has already worked, you just have to expand your regex to include newlines. I would try something like this:

regexReplace($column$,"^[^0-9].(.|\n)*","")

这应该匹配任何以非数字字符开头的文本,然后出现任意数量的字符或换行符.根据行尾,您可能需要(.|\n|\r)而不是(.|\n).

This should match any text starting with a character that is not a number, followed by any number of occurrences of any character or a newline. Depending on the line endings, you might need (.|\n|\r) instead of (.|\n).

这篇关于regexReplace in String Manipulation KNIME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆