在KETTLE中使用正则表达式替换字符串 [英] Replace string using regular expression in KETTLE

查看:4194
本文介绍了在KETTLE中使用正则表达式替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用正则表达式替换水壶中的某个模式.例如,AAAA> 5< BBBB,我要替换为AAAA 555 BBBB.我知道如何找到模式,但是我不确定如何用新的字符串替换它.我必须保持的一件事是,我必须一起找到模式>< ;,而不是像>或<因为还有另一个模式< 5>.

I would like to use regular expression for replacing a certain pattern in the Kettle. For example, AAAA >5< BBBB, I want to replace this with AAAA 555 BBBB. I know how to find the pattern, but I am not sure how to replace that with new string. The one thing I have to keep is that I have to find pattern together ><, not separately like > or < because there is another pattern <5>.

推荐答案

如果您希望将模式>\d<替换为找到的数字的三倍,则可以在正则表达式模式下使用Replace-In-String:

If you want the pattern >\d< replaced by a triple of the found digit, you can use Replace-In-String in regex mode:

Search:     (.*)(>(\d)<)(.*)
Replace:    $1$3$3$3$4

如果您希望所有这些模式都相同:

If you want all such patterns treated the same:

Search:     (>(\d)<)
Replace:    $2$2$2

由于您的要求有所提高而进行了修改

EDIT due to your improved requirement

由于您打算将简单"标记转换为更像HTML的标记,因此最好使用User-Defined-Java-Expression.另外,在重复替换时,必须避免重新引入简单的标记.

Since you intend to convert your "simple" markup to a more HTML-like markup, you better use a User-Defined-Java-Expression. Also, you must avoid to reintroduce simple markup when replacing repeatedly.

这篇关于在KETTLE中使用正则表达式替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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