Support Questions

Find answers, ask questions, and share your expertise

How to remove just only 5 characters from URL..?

avatar

I have tried replceText processor to remove first 5 letters but it doesn't work..Please suggest me the best way to remove first 5 letters in NiFi

2 REPLIES 2

avatar
Master Guru

@umang s

Try with below configurations of Replace Text processor:-

Search Value

^.{0,5}

Replacement Value

Empty string set 

Character Set

UTF-8

Maximum Buffer Size

1 MB

Replacement Strategy

Regex Replace

Evaluation Mode

Entire text

65041-replacetext.png

Input Flowfile Content:-

https://community.hortonworks.com/questions/182384/how-to-remove-just-only-5-characters-from-url.htm...

Output Flowfile Content:-

we are removing first 5 characters and replacing them with empty string, as you can see below we have removed https(first 5 characters).

://community.hortonworks.com/questions/182384/how-to-remove-just-only-5-characters-from-url.html

.

If the Answer helped to resolve your issue, Click on Accept button below to accept the answer, That would be great help to Community users to find solution quickly for these kind of issues.

avatar
Master Guru

@umang s

if you are having url as attribute to the flowfile then you can use update attribute processor with replaceFirst function to replace 5 characters with empty string.

Example:-

I'm having url attribute to the flowfile with value as

https://community.hortonworks.com/questions/182384/how-to-remove-just-only-5-characters-from-url.htm...

Now i'm using update attribute processor and added new property in update attribute processor

url

${url:replaceFirst('\w{5}', '')}

(or)

${url:replaceAll('^.{0,5}', '')}

65042-updateattribute.png

Output Flowfile Attribute value:-

65043-output.png

Now we have removed first 5 characters in url attribute value by using update attribute processor.