Reputation: 387
I'm trying to use kafka transforms.RemoveString to modify the name of my topic before passing it into my connector. My topic name looks like this
foo.bar_1.baz
I want to extract bar_1 and pass that in as the topic name. From what I can tell my regex is correct but the kafka transform doesn't seem to like it -
transforms=ReplaceField,RenameField,RemoveString
transforms.RemoveString.type=org.apache.kafka.connect.transforms.RegexRouter
transforms.RemoveString.regex=(\w*.)(\w*\d+)(.*)
transforms.RemoveString.replacement=$2
I can tell the RemoveString is being used as when I change the regex to the following I get my desired results but this is rather restrictive for my use case -
transforms.RemoveString.regex=(foo.)(.*)(.baz)
transforms.RemoveString.replacement=$2
Is there some sort of limitation to the regex usage within Kafka transforms?
Upvotes: 1
Views: 827
Reputation: 387
Found the issue, backslashes had to be escaped, with my improved regex it now looks like this -
(\\w*)\\.(\\w+)\\.(.*)
Upvotes: 1
Reputation: 2197
You have typo in RegexRouter, You missed the R
transforms=ReplaceField,RenameField,RemoveString
transforms.RemoveString.type=org.apache.kafka.connect.transforms.RegexRouter
transforms.RemoveString.regex=(\w*.)(\w*\d+)(.*)
transforms.RemoveString.replacement=$2
Upvotes: 0