- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
ReplaceTextWithMapping to replace value with space
- Labels:
-
Apache NiFi
Created on
‎10-05-2019
10:56 AM
- last edited on
‎10-05-2019
01:37 PM
by
ask_bill_brooks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I try to replace text with space using ReplaceTextWithMapping processor. I have file with multiple lines
"action":"account sing up"
"action":"account sign in"
"action":"account sign out"
And I have a mapping file with \t separating the search value and replace value
account sing up asu
account sign in asi
account sign out aso
Regular expressions "action":"(.*)"
Matching group: 1
Result
"action":"account sing up"
"action":"account sign in"
"action":"account sign out"
Expected:
"action":"asu"
"action":"asi"
"action":"aso"
Does anyone know what I did wrong?
Thanks
David
Created ‎10-09-2019 10:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello David,
The ReplaceTextWithMapping processor has been around for some time now and its design is rather simplistic in its current implementation. It is designed to match a simple regex that will map one group of non-whitespace characters to another group of characters (can have white space and back references).
in your example you are matching on a a set of characters that contains whitespaces.
If you were to add a replaceText processor to your flow to replace all the whitespace with a non-whitespace character like "-", then it will work. sample ReplaceText processor configuration:
Your mapping file would of course then be based off this change:
account-sing-up asu
account-sign-in asi
account-sign-out aso
the resulting mapping would then work:
Thank you,
Matt
Created ‎10-09-2019 10:47 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello David,
The ReplaceTextWithMapping processor has been around for some time now and its design is rather simplistic in its current implementation. It is designed to match a simple regex that will map one group of non-whitespace characters to another group of characters (can have white space and back references).
in your example you are matching on a a set of characters that contains whitespaces.
If you were to add a replaceText processor to your flow to replace all the whitespace with a non-whitespace character like "-", then it will work. sample ReplaceText processor configuration:
Your mapping file would of course then be based off this change:
account-sing-up asu
account-sign-in asi
account-sign-out aso
the resulting mapping would then work:
Thank you,
Matt
Created ‎10-09-2019 11:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. It really helps 😃
