簡體   English   中英

從字符串中提取數字

[英]Extracting digits from string

我正在嘗試從字符串中提取一些數字: foo=bar&hash=00000690821388874159\\";\\n

我嘗試為數字分組,但是它總是返回一個空字符串。

string matchString = Regex.Match(textBox1.Text, @"hash=(\d+)\\").Groups[1].Value;

我從不使用正則表達式,因此請告訴我這里缺少的內容。

您的字符串中沒有\\\\ ,實際上\\是用來轉義引號的,因此正則表達式不匹配。 這有效:

string matchString = Regex.Match(textBox1.Text, @"hash=(\d+)""").Groups[1].Value;

http://dotnetfiddle.net/2U0lkI

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM