One Star

multiple reguler expression in one file

I have text file. i need to identify multiple patten in it.
------------------------------------
eg.
data : 100
tax  : 300
hardware: 400
cost : 2000
------------------------------------
similar data will be in other files also.
so i have to write 4 regular expressions
like
1. ****
2. ****
3. ****
4. ****

how do i do that in talend.
an Example will be good.
Thanks
7 REPLIES
Employee

Re: multiple reguler expression in one file

I think you need to explain in more detail why you need to do this. For example, if it is to identify rows holding the data and extract it, you can simply use Java String methods to identify the row from finding "data" in the text and then extract the number from the string a row at a time using a tMap, for example. You can of course use a regex to do this, but from what you have given you may as well just search for the leading word (data, tax, hardware, cost). 
One Star

Re: multiple reguler expression in one file

Hi,
I didn't quite understand you(as I am new to talend).Can you give me an example???
I ll explain my problem again,
as you can see in image (Highlited red) i wrote a  regular expression and I am getting results for it.For my project I need only few values from that file. say i need 5 values from file and i have to write 5 separate regex for that.can I do that in talend and how???
Thanks,
Pankaj
Employee

Re: multiple reguler expression in one file

Whatever you are wanting to do to extract data from your file, YES you can do it with Talend. The problem I have is that your requirement is not clear. I cannot see the image that you say you have added. Maybe that will make things a bit clearer for me. 
One Star

Re: multiple reguler expression in one file

For some reason i am not able post images and file .
here is example ,
input file:

FLIGHTS STATEMENT The Supervisor
DATE: 02/09/2013 PERIODE: 1308 E‘g§$?‘§$;'§ggE$i%(9g’:f’8;DAN STS
REF: PFO/102201/1308/01 PAGE: 2/3 MASCOT
ORDRE5 13/0254 QFA NSW 2020 AUSTRALIA
N“ Jour Heure N° Vol lmmat. Type MMD (t) Prov. Dest. Distance A déduire Redevance
Day Time Flight # Registr. AC Type MTOW From To (km) Deducted Charge
1 3 07:21 QFA107 VHOJU B744 397,2 YSSY KLAX 1036 995,65
2 3 09:06 QFA7 VHOEH B744 412,7 YSSY KDFW 3689 3 608,20
3 4 09:01 QFA7 VHOEJ B744 412,7 YSSY KDFW 2872 2 809,09
4 4 10:26 QFA8 VHOEH B744 412,7 KDFW YBBN 300 293,43
5 5 08:30 QFA7 VHOEG B744 412,7 YSSY KDFW 5193 5 079,25
6 6 08:26 QFA7 VHOEJ B744 412,7 YSSY KDFW 5296 5 180,00
7 13 09:11 QFA7 VHOEE B744 412,7 YSSY KDFW 3080 3 012,54
8 14 08:59 QFA7 VHOEG B744 412,7 YSSY KDFW 3378 3 304,01
9 15 05:34 QFA107 VHOEJ B744 412,7 YSSY KLAX 3141 3 072,20
10 15 08:27 QFA11 VHOJL B744 397,2 YSSY KLAX 3208 3 083,07
11 15 08:53 QFA7 VHOEE B744 412,7 YSSY KDFW 3393 3 318,68
12 16 05:45 QFA107 VHOEF B744 412,7 YSSY KLAX 3185 3115,24
13 16 09:10 QFA11 VHOQC A388 569 YSSY KLAX 2852 3 275,51
14 16 09:19 QFA7 VHOEG B744 412,7 YSSY KDFW 3307 3 234,56
15 16 09:43 QFA93 VHOQA A388 569 YMML KLAX 3222 3 700,45
16 17 06:01 QFA93 VHOQL A388 569 YMML KLAX 1957 2 247,61
17 17 06:19 QFA107 VHOJU B744 397,2 YSSY KLAX 1142 1 097,53
18 17 09:42 QFA7 VHOEJ B744 412,7 YSSY KDFW 1946 1 903,37
19 18 05:52 QFA93 VHOQH A388 569 YMML KLAX 2235 2 566,89
20 18 06:25 QFA107 VHOEF B744 412,7 YSSY KLAX 1175 1 149,26
21 18 08:58 QFA7 VHOEG B744 412,7 YSSY KDFW 3239 3 168,05
22 18 09:10 QFA11 VHOQD A388 569 YSSY KLAX 1956 2 246,46
23 19 06:32 QFA93 VHOQI A388 569 YMML KLAX 616 707,47
24 19 09:47 QFA7 VHOEI B744 412,7 YSSY KDFW 1695 1 657,87
25 20 09:57 QFA7 VHOEG B744 412,7 YSSY KDFW 159 155,52
26 22 08:38 QFA7 VHOEG B744 412,7 YSSY KDFW 3902 3 816,53
27 23 08:29 QFA7 VHOEF B744 412,7 YSSY KDFW 3728 3 646,34
28 24 06:34 QFA93 VHOQC A388 569 YMML KLAX 991 1 138,16
29 24 06:36 QFA107 VHOJU B744 397,2 YSSY KLAX 233 223,93
30 24 09:11 QFA7 VHOEE B744 412,7 YSSY KDFW 2863 2 800,29
31 25 09:04 QFA7 VHOEF B744 412,7 YSSY KDFW 4414 4 317,32
32 26 09:06 QFA7 VHOEE B744 412,7 YSSY KDFW 4773 4 668,45
33 27 08:34 QFA7 VHOEI B744 412,7 YSSY KDFW 4498 4 399,48
34 28 09:20 QFA7 VHOEF B744 412,7 YSSY KDFW 2391 2 338,63
35 29 09:38 QFA7 VHOEI B744 412,7 YSSY KDFW 2042 1 997,27
36 30 08:46 QFA7 VHOEJ B744 412,7 YSSY KDFW 4508 4 409,26
37 31 09:23 QFA7 VHOEF B744 412,7 YSSY KDFW 2958 2 893,21

from this file i need to extract flight date ,PERIODE,REF  and 1-37 records and insert it into DB.
so basically i need to put flight date ,PERIODE,REF  for each record .(i ll need 37 row from above file (space separates values))

now plz tell me how dod i do that???
Employee

Re: multiple reguler expression in one file

Take a look at the tFileInputRegex and the tFileInputMSDelimited. You can do this with both, it just depends on how you want to achieve it and whether the structure of your file will be consistent.
One Star

Re: multiple reguler expression in one file

Hi,
If you can give me an example then i ll understand it better.
Thanks,
Pankaj
One Star

Re: multiple reguler expression in one file

Hi,
can i match regex over multiple lines
e.g
file:
Invoice Number: A123 Invoice Date: 20-Aug-14
Aircraft: A123-301 Sample airline
and i want to extract these fileds(bold once) ... how can i do that???
and yes my file structure will be same for every file.
i tried using tFileInputRegex and the tFileInputMSDelimited.

i tried with this Regex ...
**:\s*(*)\s*.****\s*(+).**\s*(*)
Thanks,
Pankaj