匹配m1 = regxuid.Match(部分);

时间:2014-05-10 11:49:09

标签: c# regex

我需要一些关于此代码的帮助

using InfinityScript;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;

namespace IpCheck
{
    public class IpCheck : BaseScript
    {
        public IpCheck()
        {
            base.PlayerConnected += new Action<Entity>((Entity player) =>
            {
                CONTROL(player);
            });
        }
        private void CONTROL(Entity player)
        {
            string lmt = "a";
            string[] lmtArrays = File.ReadAllLines(@"scripts\\\\Configs\\\\IpCheck.cfg");
            for (int i = 0; i < (int)lmtArrays.Length; i++)
            {
                string lmt1 = lmtArrays[i];
                if (lmt1.StartsWith("Admin"))
                {
                    char[] chrArray = new char[] { '=' };
                    lmt = lmt1.Split(chrArray)[1];
                    string[] parts = lmt.Split(',');
                    foreach (string part in parts)
                    {
                        string NAME = player.GetField<string>("name");
                        string IPP = player.IP.Address.ToString();
                        string GUID = player.GUID.ToString();
                        string XUID = player.Call<string>("getxuid");
                        var val = part;
                        Regex regxuid = new Regex(XUID, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                        Match m1 = regxuid.Match(part);
                        Regex regip = new Regex(IPP, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                        Match mip = regip.Match(part);
                        if (m1.Success && mip.Success)
                        {
                            Log.Write(InfinityScript.LogLevel.Info, NAME + " IP:" + IPP + " XUID:" + XUID + " GUID:" + GUID);
                            return;
                        }

                    }
                }

            }

        }
    }
}

我想读取一个文件并获取我的id和ip所以如果id存在且ip不匹配,播放器将收到通知但是当我使用if(m1.Success&amp;&amp; mip.Success)时它不起作用如果我使用它像if(m1.Success)或if(mip.Success)它的工作但我需要id和ip 谢谢

scripts\\\\Configs\\\\IpCheck.cfg
Admin=1100001f4552aav,192.168.0.15

0 个答案:

没有答案