Saturday, January 12, 2013

ตัวอย่าง match regex แล้ว assign ใส่ groups


ตัดมาจาก code ในส่วยที่เคยใช้ไป get ราคาหุ้น

    this.Html = HttpRequester.RequestHttp(string.Format(this.RequestUrl, tickerSymbol), out errorCode);
    if (errorCode < 0)
    {
        return errorCode;
    }
    string RegexPricePattern = @"<span class=""time_rtq_ticker""><span id=""[^>\t\r\n\v\f]*"">(?<price>\d*\.\d*)</span>?";
    Regex priceFinder = new Regex(RegexPricePattern, RegexOptions.IgnoreCase);
    Match priceMatch = priceFinder.Match(this.Html);
    if (priceMatch.Success)
    {
        string priceString = priceMatch.Groups["price"].Value;
    }


1 comment:

  1. Coin Casino Review 2021 : Bonuses, Software & Games
    Welcome to Coin Casino Canada ✓ ⭐ Casino Review ⭐ Free 샌즈카지노 Spins, Bonuses, 인카지노 Mobile & Casino 메리트 카지노 Review ➤ Check out our latest Casino Bonus & Play

    ReplyDelete