Regular expression question

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Regular expression question

Rick Medlin
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




[hidden email]<mailto:[hidden email]>
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.
---------------------------------------------------------------------

Reply | Threaded
Open this post in threaded view
|

Re: Regular expression question

Andy LoPresto-2
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
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On Mar 12, 2019, at 3:23 PM, Rick Medlin <[hidden email]> 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
>
>
>
>
> [hidden email]<mailto:[hidden email]>
> 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.
> ---------------------------------------------------------------------
>

Reply | Threaded
Open this post in threaded view
|

RE: Regular expression question

Rick Medlin
In reply to this post by Rick Medlin
This was resovled.

Rick M.

From: Rick Medlin
Sent: Tuesday, March 12, 2019 3:24 PM
To: '[hidden email]' <[hidden email]>
Subject: 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




[hidden email]<mailto:[hidden email]>
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.
---------------------------------------------------------------------