Logstash ruby filter conditions and referrence

(fedwe khoury) #1

hello i am still new in ruby coding and i want to ask how can i apply these conditions in ruby and my case is that i receive different numbers from different countries like +962123456 or 00962123456 or 962123456.i have a csv file that has all country codes with their country name so i want to extract the country code from the number and then use hash to link it to csv file and add its country name field

and these aaare my conditions i want to implement in ruby

if (length(calling)==7)

calling="0" calling;

else if ((length(calling)>8)&& (substr(calling,1,2) !="00") && (substr(calling,1,3) !="961") )

calling= calling;

else if (substr(calling,1,4) =="9612")

calling ="0" substr(calling,4) ;

else calling=calling;

if (length(called)==7)

called="0" called;

else if ((length(called)>8)&& (substr(called,1,2) !="00") && (substr(called,1,3) !="961") )

called= called;

else if (substr(called,1,4) =="9612")

called ="0" substr(called,4) ;

else called=called;

if (substr (calling,1,3)=="961")

calling=substr (calling,4);

while(substr(calling,1,1)=="0")

calling = substr(calling,2);

(fedwe khoury) #2

anyone?

(system) closed #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.