Common下RegHelper.cs

181 篇文章 2 订阅
14 篇文章 0 订阅
<div id="article_content" class="article_content"><p>using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;</p><p>namespace Common
{
    public class RegHelper
    {
        //返回单个路径</p><p>        public static string GetImgUrl(string HTMLStr)
        {
            string str = string.Empty;
            //string sPattern = @"^<img/s+[^>]*>";
            Regex r = new Regex(@"<img/s+[^>]*/s*src/s*=/s*([']?)(?<url>/S+)'?[^>]*>",
            RegexOptions.Compiled);
            Match m = r.Match(HTMLStr.ToLower());
            if (m.Success)
                str = m.Result("${url}");
            return str;
        }
        //返回多个路径的情况
        public static StringBuilder MyGetImgUrl(string text)
        {
            StringBuilder str = new StringBuilder();
            string pat = @"<img/s+[^>]*/s*src/s*=/s*([']?)(?<url>/S+)'?[^>]*>";</p><p>            Regex r = new Regex(pat, RegexOptions.Compiled);</p><p>            Match m = r.Match(text.ToLower());
            //int matchCount = 0;
            while (m.Success)
            {
                Group g = m.Groups[2];
                str.Append(g).Append(",");
                m = m.NextMatch();
            }
            return str;
        }
        /// <summary>
        /// 根据id过滤div内容
        /// </summary>
        /// <param name="html"></param>
        /// <param name="id">id</param>
        /// <param name="include_div_mask">是否包含div标记</param>
        /// <returns></returns>
        public static string GetDivByID(string html, string id, bool include_div_mask)
        {
            string regex_pattern = string.Format(include_div_mask ? @"(?is)<div[^>]*?id=""{0}.+?</div>" : @"(?is)(?<=<div[^>]*?id=""{0}[^>]+>).+?(?=</div>)", Regex.Escape(id));
            Match m = Regex.Match(html, regex_pattern);
            if (m.Success) return m.Value;
            else return "";
        }</p><p>
    }
}</p></div>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
NullReferenceException: Object reference not set to an instance of an object BattleStageControl.OpenBattleRewardNext () (at Assets/0.C#/Battle/BattleStageControl.cs:102) BattleStageControl.OpenBattleReward () (at Assets/0.C#/Battle/BattleStageControl.cs:70) EventCenter.Broadcast (MeventType MeventType) (at Assets/0.C#/Common/EventCenter.cs:162) FuguiState.DeleteFugui02 (System.String site, System.String FuguiName) (at Assets/0.C#/Map/FuguiState.cs:231) EventCenter.Broadcast[T,X] (MeventType MeventType, T arg1, X arg2) (at Assets/0.C#/Common/EventCenter.cs:196) SaveDataManager.DeleteFugui01 (System.String site, System.String FuguiName) (at Assets/0.C#/Common/SaveDataManager.cs:517) EventCenter.Broadcast[T,X] (MeventType MeventType, T arg1, X arg2) (at Assets/0.C#/Common/EventCenter.cs:196) FuguiActionTriger.clickToDelete () (at Assets/0.C#/Battle/FuguiActionTriger.cs:519) UnityEngine.Events.InvokableCall.Invoke () (at <c6956609c5d74f5d8e6ed4e5e5f40cc2>:0) UnityEngine.Events.UnityEvent.Invoke () (at <c6956609c5d74f5d8e6ed4e5e5f40cc2>:0) UnityEngine.UI.Button.Press () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:70) UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/UI/Core/Button.cs:114) UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:57) UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/ExecuteEvents.cs:272) UnityEngine.EventSystems.EventSystem:Update() (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:501)什么意思
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值