regex for replace/substr expression

One Star

regex for replace/substr expression

Hi all,
I have an expression with this form
SYS-Sedik-HKM-ES-20120106-140508-7891256-20120103-100624.csv
(3 caracters+"-"+5 char+"-" + 3 char +"-"+ 2 char + "-"+ date(YYYYMMDD)+"-"+date(HHMMSS)+REFERENCE+date(YYYYMMDD)+"-"+date(HHMMSS)+".csv"
I'm trying to get the REFERENCE : (in this exmeple : "7891256".)
How doing that using regex expression ?
Thanks
One Star

Re: regex for replace/substr expression

You can use following expression.
"(*-*-*-*-*-*)-(*)-(*-*.*)"
Make sure you add 3 more columns in your tExtractRegexFields middle column will carry your REFERENCE.
--
Regards,
Vinod
One Star

Re: regex for replace/substr expression

Thanks vinod_talend,
I'm not sure I understand, could you please provide me more details. thanks
One Star

Re: regex for replace/substr expression

Hi Lino,
tExtractRegexFields does 2 things, 1st it parses the string in given format and if it matches the format it passes the data to the next component otherwise it rejects the data(only particular format will pass through) and 2nd it splits the matching data in multiple fileds as per the given rule.
Rule : "(*-*-*-*-*-*)-(*)-(*-*.*)" simply says that any string which is having - seperator and contains alphabets in 1, 2, 3, 4, 10th position and numeric values in 5 ,6 ,7 ,8 ,9th position.
and those brackets tells that the string should split into three section where 2nd is string represents your REFERENCE column. So if field1 contains your string then after split there will be 4 fields field1 plus 3 splitted fileds. However to contain all split values we need to define 3 columns in tExtractRegexFields metadata.
Hope now you are clear on how to use tExtractRegexFields.
--
Regards,
Vinod