Link to home
Start Free TrialLog in
Avatar of Sean Girgis
Sean Girgis

asked on

Perl string tokenizing and paring

I am having a very complex string that I need to tokenize and also create name pair values when possible. Here is a sample of the strings I have

Recod Style 1
Search Result Queries;SomeHotel.com;PT\=89030726\;PA\=-1119567914\;PS\=1547518063;2017-05-13 01:43:36.719;Search Results Query BT SPLIT=checkInDate\=5-13-2017&checkOutDate\=5-14-2017&numberOfAdults\=1&propertyIds\=MS140|MS741|MS1290|MS1334|MS1349|MS4557|MS4568|MS4783|MS4854|SS6029,Web Requests - Client IP=50.251.11.233;Execution Time Informix=2404.003662109375,DB Count=2.0,DB Time=2404.0037887319922;false;;2424.760498046875;2424.760498046875;8.655830353498459;2424.7605440989137;;;;SomeHotel_PROD;dyntrc-mgmt.SomeHotel.com


Recod Style 2
Search Result Queries;Mobile App;PT\=89031695\;PA\=-1119567914\;PS\=1547518063;2017-05-13 01:44:17.772;Search Results Query BT SPLIT=checkInDate\=5-13-2017&checkOutDate\=5-14-2017&corporatePlusNumber\=&numberOfAdults\=1&propertyIds\=MS1173%7CMS4961%7CMS4376%7CMS4281,Web Requests - Client IP=66.115.209.42;Execution Time Informix=1762.662109375,DB Count=5.0,DB Time=1759.847623437643;false;;1781.0732421875;1781.0732421875;10.074070394039154;1781.0732627734542;;;;SomeHotel_PROD;dyntrc-mgmt.SomeHotel.com

Both record styles happen in the same file.

Main delimiter above is;
some values are name-value pairs delimited on \= or =
Some fields contain other fields and delimited by &

Any ideas on how to parse this so I can convert it to some CSV or json
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

It looks like it's already delimited by semi-colons, and some of the equal signs appear to be escaped with backslashes.  The ampersand delimiters are vaguely reminiscent of URL arguments. The %xx values may be URL encoding, too.

Where does this string of data come from?  Is there any documentation for the API?
SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The author never responded to any of the answers and never provided the additional detail needed to find out exactly what they really wanted.  As such, it should be closed with points split between those who supplied answers.