|
Post by bulldogg on Nov 4, 2008 17:10:37 GMT
first of all will this expression (\\[RDC\\]) find any string with [RDC] in it?
and second is what code can i use to check playernames on join to see if they contain the required expression?
so any playername beginning with [RDC] as an example
BD
|
|
|
Post by Eagle on Nov 4, 2008 19:22:14 GMT
I prefer using the @ sign to preceed strings to avoid having to type double backslashes in regular expressions, those things are allready hard to read so I'll give you an example of what you want as such: using System.Text.RegularExpressions; ...
private bool IsRdcMember(string playerName) { return new Regex(@"^\[RDC\]").IsMatch(playerName); }
Note that the inclusion of the ^ (caret) makes sure that only strings beginning with the tag are matched, wihout it would match strings containg that tag anywhere
|
|
|
Post by bulldogg on Nov 4, 2008 19:25:41 GMT
ah cool so the retured value would be true false, so if IsRdcMember = True? or = 1?
|
|
|
Post by Eagle on Nov 5, 2008 7:06:01 GMT
C# is a strongly typed language and therefor booleans can only be true or false, 1 per definition is an integer value and can't be assigned to or compared with a boolean value. To evaluate the result you could simply do the following:
if(IsRdcMember(playerName)) { //Do something with RDC member }
|
|