What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » RegExp help/Alternative?

RegExp help/Alternative?
Author: Message:
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
39 / Male / Flag
Joined: Mar 2007
O.P. RegExp help/Alternative?
Hey guys, as always, stuck again.
I'm trying to sort out some information from a CurrentMedia string using RegExp, but I'm nowhere near good enough at it (or understand it well enough).

code:
XBOXMSGR\0Game\01\0{0}: {1} ({2})\0Xbox 360\0Game Name\0GamerTag\0Web-Link\066262\0\0
code:
ITunes\0Music\01\0{0} - {1}\0Song\0Artist\0Album\0"

Both of these strings are taken from different Media strings by different (yet default MS) apps.  Both of them have different numbers of dividers (the "\0") and I think this is where my problems are occurring.
I was trying to use a function to retrive the information, but because I'm unsure how to make each section optional I can't get it to retrieve the final sections without stopping it working.

Lastly (I know, taking liberties now) I'd like to know if there is a way to return multiple values, so that I could set up the function to get the information I need

For example, after running the RegExp, is there a way to return $1, $2, $3, falling back onto $1, $2 if there is no $3 (etc all the way up to the 10 or whatever the value is).  The on the other end, to get just the one I want from the function (ie if the function is RunReg(), to do something such as "var variable = RunReg(2) to retrieve the second value?

can anyone help me with any of this?  I would be extremely grateful...
Cheers guys
Leroux
[Image: adsig.jpg]
01-12-2009 02:39 AM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: RegExp help/Alternative?
You can return an array...

js code:
function RunReg(){
    var myArray = new Array();
    myArray[0] = "Blah";
    myArray[1] = 404;
    myArray[2] = "example";

    return myArray;
}

function OtherFunction(){
    var ret_val = RunReg();
    Debug.Trace(ret_val[1]);
}

EDIT: Also. If you put the media message in a string:

js code:
media_string = media_string.split("\0");
for(var s in media_string){
    //Do things for each section
}

This post was edited on 01-12-2009 at 03:01 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
01-12-2009 03:00 AM
Profile PM Find Quote Report
ArkaneArkade
Full Member
***

Avatar
The One and Only

Posts: 193
Reputation: 5
39 / Male / Flag
Joined: Mar 2007
O.P. RE: RE: RegExp help/Alternative?
Thanks you Spunky.  I never considered doing it that way, but because of that quick reply, I have it all sorted now:D

Only one note:
quote:
Originally posted by Spunky

js code:
media_string = media_string.split("\0");

To work properly, needs to be
js code:
media_string = media_string.split("\\0");

Cheers man
[Image: adsig.jpg]
01-12-2009 03:32 AM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: RegExp help/Alternative?
quote:
Originally posted by Leroux
To work properly, needs to be
Javascript code:
media_string = media_string.split("\\0");

Cheers man

:p You knew what I meant though ;)

And np.
<Eljay> "Problems encountered: shit blew up" :zippy:
01-12-2009 03:44 AM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On