What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Howto] Get Personalized status

Pages: (2): « First [ 1 ] 2 » Last »
[Howto] Get Personalized status
Author: Message:
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. [Howto] Get Personalized status
A little function that I wrote, I think this might be usefull for others.

code:
function PersonalizedStatus() {
   var myRegExp = /^(.*)(\xA0\{(.+)\})$/ig;
   return myRegExp.exec(Messenger.MyName);
}

This function will return null when there is no personalized status, else it will return an array with the following elements:

0 --> The whole display name including the personalized status
1 --> The display name without the personalized status
2 --> The personalized status part, including the { } and the special character before it
3 --> The personalized status without the { } around it, so just the text
07-01-2006 12:44 PM
Profile E-Mail PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: [Howto] Get Personalized status
quote:
Originally posted by J-Thread
/^(.*)(\xA0\{(.+)\})$/ig
Man, I really need to learn Regex! That makes no sense to me at all.

Edit: Actually, it does make sense to me. I think I may end up using that myself, but maybe with less parenthises :P like /^.*\xA0\{.+\}$/ig, which should also work.

This post was edited on 07-01-2006 at 01:56 PM by RaceProUK.
[Image: spartaafk.png]
07-01-2006 01:54 PM
Profile PM Web Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: RE: [Howto] Get Personalized status
quote:
Originally posted by RaceProUK
quote:
Originally posted by J-Thread
/^(.*)(\xA0\{(.+)\})$/ig
Man, I really need to learn Regex! That makes no sense to me at all.

Edit: Actually, it does make sense to me. I think I may end up using that myself, but maybe with less parenthises :P like /^.*\xA0\{.+\}$/ig, which should also work.


The brackets are needed, they group the stuff that's to be returned in the array (see first post).
The previous sentence is false. The following sentence is true.
07-01-2006 01:58 PM
Profile PM Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: [Howto] Get Personalized status
Ah, I see.
[Image: spartaafk.png]
07-01-2006 05:15 PM
Profile PM Web Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: [Howto] Get Personalized status
quote:
Originally posted by J-Thread
/^(.*)(\xA0\{(.+)\})$/ig
omfg. I can't believe I didn't add "\xA0". I knew something was missing. :P

Thanks a lot, J-Thread. (Y) This is very useful.

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

07-01-2006 05:21 PM
Profile PM Find Quote Report
mathieumg
Full Member
***


Posts: 181
Reputation: 2
35 / Male / Flag
Joined: May 2004
RE: [Howto] Get Personalized status
Haven't tested it, but there may be more than one { } pair, does it always take the last one?
Official MessengerPlus! Live French Translator
Official StuffPlug 3 French Translator

:)
07-02-2006 05:39 AM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
O.P. RE: [Howto] Get Personalized status
Yes, if you know some regular expressions, you can easily see that. The ^ stands for the beginning of the name, and the $ for the end. So to be able to find a match, there have to be a certain number (0 or more) characters (any characters you like) at the beginning of the string, then ASCII character 160 (\xA0), then a {, then 1 or more characters, then a } and that must be the end of the string. Exactly what you would do when you had to describe the process of finding the personal message in english.
07-02-2006 10:49 AM
Profile E-Mail PM Find Quote Report
ulyxes
Junior Member
**


Posts: 21
36 / Male / –
Joined: Jun 2006
RE: [Howto] Get Personalized status
Sorry, I actually don't know Regex... Where do I have to attach this script? Thanks a lot for your help!
07-02-2006 11:40 AM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: [Howto] Get Personalized status
quote:
Originally posted by J-Thread
Yes, if you know some regular expressions, you can easily see that. The ^ stands for the beginning of the name, and the $ for the end. So to be able to find a match, there have to be a certain number (0 or more) characters (any characters you like) at the beginning of the string, then ASCII character 160 (\xA0), then a {, then 1 or more characters, then a } and that must be the end of the string. Exactly what you would do when you had to describe the process of finding the personal message in english.
That's still not a complete explanation: the * operator is greedy, and will match as many characters as possible. This way, no matter how many '\xA0{'s there are, .* will skip all but the last.
[Image: spartaafk.png]
07-02-2006 02:09 PM
Profile PM Web Find Quote Report
segosa
Community's Choice
*****


Posts: 1407
Reputation: 92
Joined: Feb 2003
RE: RE: [Howto] Get Personalized status
quote:
Originally posted by RaceProUK
quote:
Originally posted by J-Thread
Yes, if you know some regular expressions, you can easily see that. The ^ stands for the beginning of the name, and the $ for the end. So to be able to find a match, there have to be a certain number (0 or more) characters (any characters you like) at the beginning of the string, then ASCII character 160 (\xA0), then a {, then 1 or more characters, then a } and that must be the end of the string. Exactly what you would do when you had to describe the process of finding the personal message in english.
That's still not a complete explanation: the * operator is greedy, and will match as many characters as possible. This way, no matter how many '\xA0{'s there are, .* will skip all but the last.


How did you go from "Man, I really need to learn Regex! That makes no sense to me at all." to an expert? Were you sarcastic with your original post or are you just a quick learner?
The previous sentence is false. The following sentence is true.
07-02-2006 03:52 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« 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