Regular expresission to split line

时间:2017-06-15 09:43:29

标签: regex apache-nifi

I need regular expression to split following text

es7600: indv_nr, ksl_dato, se_nr, cvr_nr, annul_kod, projekt_kod, virk_start_dto, virk_oph_dto, abon_status_kod, virk_kod, virk_type_txt

I need to capture the text before colon and after colon

var = regex # result es7600
var1 = indv_nr, ksl_dato, se_nr, cvr_nr, annul_kod, projekt_kod......

I guess the question is, how to grab everything before the : and everything after the colon

In this case i need the clean regex as NIFI extractText does not support expressionlanguage

2 个答案:

答案 0 :(得分:2)

Is this what you're after?

([^:]+): *([^$]+)

demo

Group1 captures everything before the colon
Group2 captures everything after the colon (and zero or more space chars)

答案 1 :(得分:2)

i assume you have es7600: indv_nr, ksl_dato, ..... as a flowfile content

then you can use ExtractText processor with adding new dynamic parameter:

MyKey with value ([^:]+):(.*)

also you may set to true Enable DOTALL Mode and Enable Multiline Mode

after execution if content matches the regexp above you should have new attributes in your flow file:

MyKey.1 will contain the value before :

MyKey.2 will contain the value after :