Discuz!NT
欢迎 游客 , 注册 | 登录 | 会员 | 界面 | 简洁版本 | 在线 | 帮助
商都网教育宝典宝库

发表新主题 回复该主题
本主题被查看1006次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第   上一主题   下一主题
标题: 批量字符串替换程序-1
张小峰
超级版主
UID: 14
来自:
精华: 4
积分: 313
帖子: 285
注册: 2007-8-23 10:27:00
状态: 离线
威望: 8.00
金钱: 75.55 元
只看楼主 2007-08-30 09:46
批量字符串替换程序-1
(1)PairString

1    public struct PairString
2    {
3        public string OldValue;
4        public string NewValue;
5        public bool IsRightFilter;
6        public bool IsLeftFilter;
7
8        public PairString(string oldValue, string newValue)
9        {
10            OldValue=oldValue;
11            NewValue=newValue;
12            IsRightFilter=true;
13            IsLeftFilter=true;
14        }
15
16        public PairString(string oldValue, string newValue, bool isRightFilter, bool isLeftFilter)
17        {
18            OldValue=oldValue;
19            NewValue=newValue;
20            IsRightFilter=isRightFilter;
21            IsLeftFilter=isLeftFilter;
22        }
23    }

2    {
3        private PairString[] _filterSet=null;
4
5        public PairString[] FilterSet
6        {
7            get
8            {
9                return _filterSet;
10            }
11            set
12            {
13                _filterSet=value;
14            }
15        }
16
17
18        public StringFilter()
19        {
20        }
21
22
23        public virtual  string Filter(string input)
24        {
25            foreach (PairString p in FilterSet)
26            {


  if(p.IsRightFilter==true) input=input.Replace(p.OldValue,p.NewValue);
28            }
29            return input;
30        }
31
32        public virtual string AntiFilter(string input)
33        {
34            foreach (PairString p in FilterSet)
35            {
36                if(p.IsLeftFilter==true) input=input.Replace(p.NewValue,p.OldValue);
37            }
38            return input;
39        }
40    }
#1  
发表新主题 回复该主题
本主题被查看1006次, 共1个帖子, 1页, 当前为第1页     选择页数: 1      跳转到第







现在的时间是 2008-10-08 11:41:16

版权所有 商都网教育宝典
         Powered by Discuz!NT 1.0.6666    Copyright © 2001-2008 Comsenz Inc.
Processed in 0 seconds