Need some help in creating Regex Expression

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

Need some help in creating Regex Expression

ravva
Hello - I have input files as below

CanadaCST_prices.csv
CanadaEST_prices.csv
CanadaMST_prices.csv
CanadaPST_prices.csv
cst_prices.csv
est_prices.csv
mst_prices.csv
pst_prices.csv

I have to write 2  regex expressions where in one of them I need to get only
the file names that are starting with cst,est,mst,pst . In the second regex
I need to pull the files that are starting with
CanadaCST,CanadaEST,CanadaPST,CanadaMST.

Can someone suggest on how to create a regex for this scenario.

Thanks,

 



--
Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Need some help in creating Regex Expression

Andy LoPresto-2
These two expressions should work:

^[cemp]st.*\.csv

^Canada[CEMP]ST.*\.csv

Andy LoPresto
[hidden email]
[hidden email]
PGP Fingerprint: 70EC B3E5 98A6 5A3F D3C4  BACE 3C6E F65B 2F7D EF69

> On May 31, 2019, at 9:47 AM, ravva <[hidden email]> wrote:
>
> Hello - I have input files as below
>
> CanadaCST_prices.csv
> CanadaEST_prices.csv
> CanadaMST_prices.csv
> CanadaPST_prices.csv
> cst_prices.csv
> est_prices.csv
> mst_prices.csv
> pst_prices.csv
>
> I have to write 2  regex expressions where in one of them I need to get only
> the file names that are starting with cst,est,mst,pst . In the second regex
> I need to pull the files that are starting with
> CanadaCST,CanadaEST,CanadaPST,CanadaMST.
>
> Can someone suggest on how to create a regex for this scenario.
>
> Thanks,
>
>
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Need some help in creating Regex Expression

Endre Kovács
In reply to this post by ravva
Hi,

Also when in doubt, you can always experiment, check and learn regex in online places like:

https://regex101.com/#pcre <https://regex101.com/#pcre>
or
https://regexr.com/ <https://regexr.com/>

where you can also specify a test string you want to match for.
Best regards,
Endre

> On 31 May 2019, at 18:47, ravva <[hidden email]> wrote:
>
> Hello - I have input files as below
>
> CanadaCST_prices.csv
> CanadaEST_prices.csv
> CanadaMST_prices.csv
> CanadaPST_prices.csv
> cst_prices.csv
> est_prices.csv
> mst_prices.csv
> pst_prices.csv
>
> I have to write 2  regex expressions where in one of them I need to get only
> the file names that are starting with cst,est,mst,pst . In the second regex
> I need to pull the files that are starting with
> CanadaCST,CanadaEST,CanadaPST,CanadaMST.
>
> Can someone suggest on how to create a regex for this scenario.
>
> Thanks,
>
>
>
>
>
> --
> Sent from: http://apache-nifi-developer-list.39713.n7.nabble.com/