Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Parsing text on Pronto
This thread has 6 replies. Displaying all posts.
Post 1 made on Sunday March 29, 2009 at 16:30
macdonm2
Long Time Member
Joined:
Posts:
January 2008
12
Hi,

I wonder if I can ask for some help again - I need to parse some text which I receive from my Kivor server - It will send me album info for 10 albums at a time, and I need to break this down into individual albums.

The code that I am using is as follows;

var search_name = /<NAME>(((\w|\s|\%|\$|\"|\'|\~|\!|\.|\\|\,|\/|[|]|\(|\))+))</g;

var name_result = full_output[0].match(search_name);

which matches the text after the <NAME> header through to <

The problem I have is that if I omit the 'g' global switch on the end I get everything between the <NAME> and <, but as I want to search multiple times I need the 'g' switch and the output is something like;

<NAME>The Beatles<

I know I can parse this output again, but is there a more elegant way to do this in the original search ?

Any suggestions would be greatly appreciated.

Regards,

Mike.

Last edited by macdonm2 on March 30, 2009 05:47.
macdonm2
Post 2 made on Sunday March 29, 2009 at 16:55
mraneri
Long Time Member
Joined:
Posts:
February 2009
141
I'm not good at parsing regexp myself. What exactly is the Kivor server returning? Why don't you use some sort of .split("") to create an array of the 10 albums?

Perhaps an example of the Kivor output, and an explanation of what you're trying to do with the ten album names might help...

- Mike
OP | Post 3 made on Sunday March 29, 2009 at 17:18
macdonm2
Long Time Member
Joined:
Posts:
January 2008
12
Hi Mike,

Thanks for the reply. The Kivor returns up to 10 albums in a single string in roughly the following format

...<NAME>1<ARTIST>The Beatles<GENRE>Rock<ID>667<NAME>A kind of Magic<ARTIST>Queen<GENRE>Rock<ID>22<NAME>............

What I am doing is parsing out each of the fields and then writing each to an Array to allow me to search on whichever field I want. Not sure whether split would work in this instance or not.

Thanks,

Mike.

Last edited by macdonm2 on March 30, 2009 05:34.
macdonm2
OP | Post 4 made on Sunday March 29, 2009 at 17:28
macdonm2
Long Time Member
Joined:
Posts:
January 2008
12
Hmm - just realised that my post is not displaying correctly as the browser must be reading the tags - how do i post text so that the tag won't be read ?

Thanks,

Mike.
macdonm2
Post 5 made on Sunday March 29, 2009 at 21:13
Lyndel McGee
RC Moderator
Joined:
Posts:
August 2001
13,003
You must escape less-than, greater than, etc which this site interprets as HTML markup.
Lyndel McGee
Philips Pronto Addict/Beta Tester
OP | Post 6 made on Monday March 30, 2009 at 05:35
macdonm2
Long Time Member
Joined:
Posts:
January 2008
12
Thanks Lyndel - post updated accordingly.
macdonm2
Post 7 made on Monday March 30, 2009 at 08:21
mraneri
Long Time Member
Joined:
Posts:
February 2009
141
Not sure there's a more elegant way. Not being a regexp expert myself, I would probably split on the first field in the album and then loop through the resulting array and break it up from there.
If the fields from each album come back in a known format each time, (i.e. no fields omitted and same order) you can probably do a "replace" to remove the tags, leaving just a ">" for instance, and then split the record (for each album) on ">" in the loop.

I agree, though, sounds like there's gotta be a better way...


Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse