Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

Regex # Special Character Escape

avatar

I'm trying to use regex to match the line:
# DOG CAT BIRD

NiFi regex seems to treat # as a comment character, whereas other regexes do not.

How do I match the literal character # in a string with regex?


The doc page https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#escaping doesn't seem to help me out here.

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Nick Stantzos

You can ignore the unexpected coloring rendered by the NiFi Expression language editor window.
The java regex replace should work just using "# DOG CAT BIRD" or "\# DOG CAT BIRD".


Thank you,

Matt

View solution in original post

4 REPLIES 4

avatar
Contributor

Did you try using '\' character?

avatar

With the '\' character, the '#' character still highlights the text after it as a comment:

108373-1556809188675.png

avatar
Master Mentor

@Nick Stantzos

You can ignore the unexpected coloring rendered by the NiFi Expression language editor window.
The java regex replace should work just using "# DOG CAT BIRD" or "\# DOG CAT BIRD".


Thank you,

Matt

avatar

Thanks Matt, I didn't realize that the colored text was not a comment in this case.