正则表达式查找具有指定格式的字符串 [英] Regex to find a string with a specified format

查看:179
本文介绍了正则表达式查找具有指定格式的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我必须从配置文件中读取用户指定的格式,并解析该格式是否与给定数据匹配。例如,如果用户指定< format> abc *< / format>,那么我应检查输入字符串是否以abc开头。如果用户指定< format> * abc< / format>然后我应该检查输入字符串是否以abc结尾。有人可以帮忙。

谢谢。

解决方案

这个问题的答案在于主题标题。使用 System.Text.RegularExpressions 命名空间。

Hi,

 I have to read a format specified by a user from a configuaration file and parse whether that format matches with the given data. for example if the user specifies <format>abc*</format>, then i should check whether the input string starts with abc. if the user specifies <format>*abc</format> then i should check whether the input string ends with abc. can someone pls help on this.

Thanks.

解决方案

The answer to this question lies in the thread title.  Make use of the System.Text.RegularExpressions namespace.


这篇关于正则表达式查找具有指定格式的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆