File Filter regular expression - GetFile

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

File Filter regular expression - GetFile

shankhamajumdar
Hi,

I want to get the list of files from a directory where file name starts with a. I am using  File Filter regular expression where default value is [^\.].*. But using this value I am getting all the files. Please let me know what I need to use in the File Filter regular expression section so that I can get the list of files where  file name starts with a.

Regards,
Shankha
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

shankhamajumdar
Hi,

Just a small modification, I am using ListFile processor. For example in the directory I have 5 files which are
test.txt, ab.txt, ab1.txt. If I use [ab].* in the regular expression I am getting both the files i.e. ab.txt and ab1.txt. But I just want to get ab.txt not ab1.txt. Please let me know how to resolve this.

Regards,
Shankha
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

James Wing
The .* in your regular expression is allowing all characters.  You can
escape this and specify a literal dot with a backslash, like \.

Try [ab]+\..* for example.


On Wed, Jun 28, 2017 at 2:55 AM, shankhamajumdar <
[hidden email]> wrote:

> Hi,
>
> Just a small modification, I am using ListFile processor. For example in
> the
> directory I have 5 files which are
> test.txt, ab.txt, ab1.txt. If I use [ab].* in the regular expression I am
> getting both the files i.e. ab.txt and ab1.txt. But I just want to get
> ab.txt not ab1.txt. Please let me know how to resolve this.
>
> Regards,
> Shankha
>
>
>
> --
> View this message in context: http://apache-nifi-developer-
> list.39713.n7.nabble.com/File-Filter-regular-expression-
> GetFile-tp16279p16280.html
> Sent from the Apache NiFi Developer List mailing list archive at
> Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

Yolanda Davis
In reply to this post by shankhamajumdar
Hello Shankha,

Give the below a try:

ab\.[\w]*

That should match any files that start with "ab." (with any word character
in the extension).

Please let me know if that works for you.

Best Regards,

Yolanda


On Wed, Jun 28, 2017 at 5:55 AM, shankhamajumdar <
[hidden email]> wrote:

> Hi,
>
> Just a small modification, I am using ListFile processor. For example in
> the
> directory I have 5 files which are
> test.txt, ab.txt, ab1.txt. If I use [ab].* in the regular expression I am
> getting both the files i.e. ab.txt and ab1.txt. But I just want to get
> ab.txt not ab1.txt. Please let me know how to resolve this.
>
> Regards,
> Shankha
>
>
>
> --
> View this message in context: http://apache-nifi-developer-
> list.39713.n7.nabble.com/File-Filter-regular-expression-
> GetFile-tp16279p16280.html
> Sent from the Apache NiFi Developer List mailing list archive at
> Nabble.com.
>



--
--
[hidden email]
@YolandaMDavis
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

shankhamajumdar
In reply to this post by James Wing
Thanks James,

It's working fine.

Regards,
Shankha
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

shankhamajumdar
Hi,

I have one more requirement. I have 5 files in a directory.

1. Test1.txt
2. Test12.txt
3. Test123.txt
4. Test1234.txt
5. Test12345.txt

I want to get all the files by using Test in the File Filter Regex section of ListFile processor. I don't want give full file name. Please let me know how to resolve this.
Reply | Threaded
Open this post in threaded view
|

Re: File Filter regular expression - GetFile

Chris Herrera
Hi.

This will give you want you want: ^Test.*txt. Or you could leave off the txt to allow you to get all files not just the ones ending in txt.

In case you were not aware, http://regexr.com is a great resource for developing regex.

Regards,
Chris

On Jun 30, 2017, 6:24 AM -0500, shankhamajumdar <[hidden email]>, wrote:

> Hi,
>
> I have one more requirement. I have 5 files in a directory.
>
> 1. Test1.txt
> 2. Test12.txt
> 3. Test123.txt
> 4. Test1234.txt
> 5. Test12345.txt
>
> I want to get all the files by using Test in the File Filter Regex section
> of ListFile processor. I don't want give full file name. Please let me know
> how to resolve this.
>
>
>
> --
> View this message in context: http://apache-nifi-developer-list.39713.n7.nabble.com/File-Filter-regular-expression-GetFile-tp16279p16314.html
> Sent from the Apache NiFi Developer List mailing list archive at Nabble.com.