C#如何用正则表达式从网页源文件里筛选东西

来源:百度知道 编辑:UC知道 时间:2024/05/01 09:27:37
我想做一个百度贴吧发贴的软件
但是有几个数据是要从表单里用正则抓取
怎么用正则表达式来抓取??

<input type=hidden name=bs value="C8ADC15E27FB3838EFC92AAA9B9672729DD7F639A7A3750B970FD72BC54BD685A8DF4740022B27EF95A632D5D1CC230DAAB0ED1E7B6FF82AF6EB54CCAB89">
<input type=hidden name=str3 value="BA24925B461A004EFDE758506E7F551E">
<input type=hidden name=str4 value="39504033001986423360">
<input type=hidden name=lm value="20998" >

lm,str3,str4,bs
都不是固定的值

哪位高手懂- =?
要获得

C8ADC15E27FB3838EFC92AAA9B9672729DD7F639A7A3750B970FD72BC54BD685A8DF4740022B27EF95A632D5D1CC230DAAB0ED1E7B6FF82AF6EB54CCAB89

BA24925B461A004EFDE758506E7F551E

39504033001986423360

20998

这些数据

你是要获取到value的值???

也很简单

value="BA24925B461A004EFDE758506E7F551E"

value="头
"结尾

那么正则就是value="(.*?)"

以上随你的补充而修改!

你啥意思???你是要获取这些个动态值???

也就是说你要获取im,str3,str4,bs这些数据??

仔细分析了下
name=str4

name=这一段固定

name=str4 value

中间有一个空格

而且是固定的,这就好办了!!

那么正则可以这么写 name=(.*?)\s

总体代码:

using System;
using System.Collections;
using System.Text;
using System.Text.RegularExpressions;
//using Google;
namespace ABC
{
public class TS
{
static void Main(string[] args)
{
string S=@"<input type=hidden name=bs value=""C8ADC15E27FB3838EFC92AAA9B9672729DD7F639A7A3750B970FD72BC54BD685A8DF4740022B27EF95A632D5D1CC230DAAB0ED1E7B6FF82AF6EB54CCAB89"">
<input type=hidden name=str3 value=""BA249