You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nifi.apache.org by Rick Medlin <Ri...@MedImpact.com> on 2019/03/12 22:23:40 UTC
Regular expression question
Hi,
I'm trying to filter for a particular file name and I've tried both of these expressions. The file name begins with e510:
${filename:contains('e510')}
${filename:startsWith('e510')}
Both of them return errors saying that they are not valid Java Regular Expressions. I'm new to Nifi so I don't know if something is off in our environment or not. Any assistance would be appreciated.
Rick Medlin
Software Engineer IV
858-790-6495 office
rick.medlin@medimpact.com<ma...@medimpact.com>
www.medimpact.com<http://www.medimpact.com/>
MedImpact Healthcare Systems, Inc.
10181 Scripps Gateway Ct.
San Diego, CA 92131
---------------------------------------------------------------------
This transmission, together with any attachments, is intended only for the use of those to whom it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law and/or may contain confidential individually identifiable health information protected under the Health Insurance Portability and Accountability Act of 1996 ("HIPAA") and other statutes. If you are not the intended recipient, you are hereby notified that any distribution or copying of this transmission is strictly prohibited. If you received this transmission in error, please notify the original sender immediately and delete this message, along with any attachments, from your computer.
---------------------------------------------------------------------
Re: Regular expression question
Posted by Andy LoPresto <al...@apache.org>.
Hi Rick,
If you are putting these into a field like “Filename Filter” in the GetFile processor, it is not expecting NiFi Expression Language but a Java regular expression. To accomplish this, use a string like the following (before the <— indicating an explanation):
^e510.* <— Must start with ‘e510’ then allows any number of subsequent characters
.*e510.* <— Allows any string containing ‘e510’
^e510.*\.xml <— Accepts any file that starts with ‘e510’ and ends with ‘.xml’
For more information, you can read about how Java parses regular expressions here [1].
If you are attempting to do an Expression Language evaluation, ensure the property you are using is marked “Supports Expression Language: True (Scope: Attributes)” in the docs (or mouse over the small “?” icon).
[1] https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html
Andy LoPresto
alopresto@apache.org
alopresto.apache@gmail.com
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4 BACE 3C6E F65B 2F7D EF69
> On Mar 12, 2019, at 3:23 PM, Rick Medlin <Ri...@MedImpact.com> wrote:
>
> Hi,
>
> I'm trying to filter for a particular file name and I've tried both of these expressions. The file name begins with e510:
>
> ${filename:contains('e510')}
> ${filename:startsWith('e510')}
>
> Both of them return errors saying that they are not valid Java Regular Expressions. I'm new to Nifi so I don't know if something is off in our environment or not. Any assistance would be appreciated.
>
> Rick Medlin
> Software Engineer IV
>
> 858-790-6495 office
>
>
>
>
> rick.medlin@medimpact.com<ma...@medimpact.com>
> www.medimpact.com<http://www.medimpact.com/>
>
> MedImpact Healthcare Systems, Inc.
> 10181 Scripps Gateway Ct.
> San Diego, CA 92131
>
>
>
>
>
> ---------------------------------------------------------------------
> This transmission, together with any attachments, is intended only for the use of those to whom it is addressed and may contain information that is privileged, confidential, and exempt from disclosure under applicable law and/or may contain confidential individually identifiable health information protected under the Health Insurance Portability and Accountability Act of 1996 ("HIPAA") and other statutes. If you are not the intended recipient, you are hereby notified that any distribution or copying of this transmission is strictly prohibited. If you received this transmission in error, please notify the original sender immediately and delete this message, along with any attachments, from your computer.
> ---------------------------------------------------------------------
>