社区
C#
帖子详情
Regex怎么用?
walar
2009-04-13 11:22:36
Regex regx;
我应该regx.什么设置他的比对正则表达式呢?
...全文
1693
13
打赏
收藏
Regex怎么用?
Regex regx; 我应该regx.什么设置他的比对正则表达式呢?
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
13 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
shaw
2010-01-13
打赏
举报
回复
谢谢诶!
huangzhe10
2009-05-25
打赏
举报
回复
正则表达式也太复杂了吧!
中文与英文的啊!再复杂的!
huangzhe10
2009-05-25
打赏
举报
回复
正则表达式也太复杂了吧!
中文与英文的啊!再复杂的!
huangzhe10
2009-05-25
打赏
举报
回复
正则表达式也太复杂了吧!
中文与英文的啊!再复杂的!
十八道胡同
2009-04-13
打赏
举报
回复
学习
wuyq11
2009-04-13
打赏
举报
回复
Regex是从字符窗中查找匹配字符串的应用类。通过Regex,能够非常方便的从一段数据中提取自己所需要的数据信息。
Regex regex = new Regex(@"d+");
Match m = regex.Match("aaa");
Console.WriteLine(m.Value.ToString());
参考
claymore1114
2009-04-13
打赏
举报
回复
引用命名空间 using System.Text.RegularExpressions;
//删除脚本
Htmlstring = Regex.Replace(Htmlstring, @" <script[^>]*?>.*? </script>", "", RegexOptions.IgnoreCase);
cxk106
2009-04-13
打赏
举报
回复
你想说的是:regex.Replace(string,string)?
ljhcy99
2009-04-13
打赏
举报
回复
你先看看msdn 了解下基本内容阿
from911cs
2009-04-13
打赏
举报
回复
不明白,你是要问正则表达式的一般匹配,还是什么啊!
cxk106
2009-04-13
打赏
举报
回复
public static bool IsEnglisCh(string input)
{
Regex regex = new Regex("^[A-Za-z]+$");
return regex.IsMatch(input);
}
teerhu
2009-04-13
打赏
举报
回复
public class PageValidate
{
private static Regex RegNumber = new Regex("^[0-9]+$");
private static Regex RegNumberSign = new Regex("^[+-]?[0-9]+$");
private static Regex RegDecimal = new Regex("^[0-9]+[.]?[0-9]+$");
private static Regex RegDecimalSign = new Regex("^[+-]?[0-9]+[.]?[0-9]+$"); //等价于^[+-]?\d+[.]?\d+$
private static Regex RegEmail = new Regex("^[\\w-]+@[\\w-]+\\.(com|net|org|edu|mil|tv|biz|info)$");//w 英文字母或数字的字符串,和 [a-zA-Z0-9] 语法一样
private static Regex RegCHZN = new Regex("[\u4e00-\u9fa5]");
public PageValidate()
{
}
#region 数字字符串检查
/// <summary>
/// 检查Request查询字符串的键值,是否是数字,最大长度限制
/// </summary>
/// <param name="req">Request</param>
/// <param name="inputKey">Request的键值</param>
/// <param name="maxLen">最大长度</param>
/// <returns>返回Request查询字符串</returns>
public static string FetchInputDigit(System.Web.HttpRequest req, string inputKey, int maxLen)
{
string retVal = string.Empty;
if (inputKey != null && inputKey != string.Empty)
{
retVal = req.QueryString[inputKey];
if (null == retVal)
retVal = req.Form[inputKey];
if (null != retVal)
{
retVal = SqlText(retVal, maxLen);
if (!IsNumber(retVal))
retVal = string.Empty;
}
}
if (retVal == null)
retVal = string.Empty;
return retVal;
}
/// <summary>
/// 是否数字字符串
/// </summary>
/// <param name="inputData">输入字符串</param>
/// <returns></returns>
public static bool IsNumber(string inputData)
{
System.Text.RegularExpressions.Match m = RegNumber.Match(inputData);
return m.Success;
}
/// <summary>
/// 是否数字字符串 可带正负号
/// </summary>
/// <param name="inputData">输入字符串</param>
/// <returns></returns>
public static bool IsNumberSign(string inputData)
{
System.Text.RegularExpressions.Match m = RegNumberSign.Match(inputData);
return m.Success;
}
/// <summary>
/// 是否是浮点数
/// </summary>
/// <param name="inputData">输入字符串</param>
/// <returns></returns>
public static bool IsDecimal(string inputData)
{
System.Text.RegularExpressions.Match m = RegDecimal.Match(inputData);
return m.Success;
}
/// <summary>
/// 是否是浮点数 可带正负号
/// </summary>
/// <param name="inputData">输入字符串</param>
/// <returns></returns>
public static bool IsDecimalSign(string inputData)
{
System.Text.RegularExpressions.Match m = RegDecimalSign.Match(inputData);
return m.Success;
}
#endregion
#region 中文检测
/// <summary>
/// 检测是否有中文字符
/// </summary>
/// <param name="inputData"></param>
/// <returns></returns>
public static bool IsHasCHZN(string inputData)
{
System.Text.RegularExpressions.Match m = RegCHZN.Match(inputData);
return m.Success;
}
#endregion
#region 邮件地址
/// <summary>
/// 是否是浮点数 可带正负号
/// </summary>
/// <param name="inputData">输入字符串</param>
/// <returns></returns>
public static bool IsEmail(string inputData)
{
System.Text.RegularExpressions.Match m = RegEmail.Match(inputData);
return m.Success;
}
#endregion
}
moonshineidolon
2009-04-13
打赏
举报
回复
set regex=new Regexp
regex.Multiline=True
regex.Global=True
regex.IgnoreCase=True
regex.Pattern="(\(\d{3}\)|\d{3}-)?\d{8}"
if regex.Test("83768888") then
Response.Write "匹配"
else
Response.Write "不匹配"
end if
ts-generics-
RegEx
-engine:袋装的少数功能仅支持由Typescript泛型编写的
RegEx
引擎
使用静态类型编写的
RegEx
引擎? 在编译时评估
RegEx
“模板”的代码,这样您可以在运行应用程序之前知道结果吗?
RegEx
引擎可以处理O(0)运行时复杂性吗? 缩小的0位(GZip)长度输出? 完全错误并且还没有准备好...
regex
-2021.8.3-cp37-cp37m-win32
regex
-2021.8.3-cp37-cp37m-win32
DFA_and_
Regex
_Toolbox:这是 Automata Toolkit 项目的 DFA 和
Regex
工具箱
: 用 Python 编写代码高度Modularized 抽象维护由于inline comments可读性奇迹般有效 :grinning_face_with_big_eyes:如何使用 ? 下载 [预发布版本] ( ) 同时下载 [源代码] ( )如何使用源代码? $ cd Automata_...
ip-
regex
:匹配IP地址的正则表达式
如果要支持较旧的浏览器,请使用版本2.1.0: npm install ip-
regex
@2.1.0用法 const ip
Regex
= require ( 'ip-
regex
' ) ;// Contains an IP address?ip
Regex
( ) . test ( 'unicorn 192.168.0.1' ) ;//=> true// Is...
Pawn.
Regex
::magnifying_glass_tilted_right:插件,该插件在Pawn中添加了对正则表达式的支持
native
Regex
:
Regex
_New ( const pattern[], E_
REGEX
_FLAG: flags =
REGEX
_DEFAULT, E_
REGEX
_GRAMMAR: grammar =
REGEX
_ECMASCRIPT); native
Regex
_Delete ( &
Regex
: r); native
Regex
_Check ( const str[],
Regex
...
C#
111,092
社区成员
642,554
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章