如何编写正则表达式? [英] How to write Regex Pattern ?

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

问题描述

HI,



谁能告诉我如何写正则表达式字符串模式?



下面是什么代码表示 -



正则表达式regex =新的正则表达式(\\< [^ \\>] * \\>) ;



Can anyone tell me how to write regex string pattern?

What below code indicates-

Regex regex = new Regex("\\<[^\\>]*\\>");

推荐答案

同时查看问题中的表示并回复其他解决方案。我虽然与你分享这篇非常简单和精确的文章。它将非常容易地向您解释 Regex Fundamentals



轻松学习正则表达式(RegEx)





进一步解释你发布的正则表达式,你可以看看下面



/ \\< [ ^ \\>] * \\>/

\\匹配字符\字面上

<匹配字符<字面上

[^ \\>] *匹配下面列表中不存在的单个字符

量词:在零和无限次之间,尽可能多次,根据需要回馈[贪心]

\\匹配字符\字面上

>列表中的单个字符>字面意思(区分大小写)

\\匹配字符\字面意思

>匹配字符>字面意思





如果将来有任何解释,请访问以下链接。



Regex Tester / Explainer



希望它会有所帮助。:)
while looking at the "Indicates" in your question and the reply to other solution posted. I though of sharing this very easy and precise article with you. It will explain you the Regex Fundamentals very easily.

Learn Regular Expressions (RegEx) with Ease


Further for the explanation of your posted Regex, You can have a look below

/\\<[^\\>]*\\>"/
\\ matches the character \ literally
< matches the character < literally
[^\\>]* match a single character not present in the list below
Quantifier: Between zero and unlimited times, as many times as possible, giving back as needed [greedy]
\\ matches the character \ literally
> a single character in the list > literally (case sensitive)
\\ matches the character \ literally
>" matches the characters >" literally


And for any explanation in future, Do visit the following link.

Regex Tester/Explainer

Hope it will help. :)


原始表格应该是:

the original form should be :
\<[^\>]*\>



额外的\只是为了c#而逃避\。

它将匹配'<'和'>'所包含的任何内容或任何内容。

*表示出现零次或多次。


the extra \ is just to escape \ for the sake of c#.
It will match anything or nothing that is enclosed with '<' and '>'
The * means occurring zero or more times.


将此电子书下载到学习正则表达式



http://it-ebooks.info/book/920/ [ ^ ]



祝你好运
Download this eBook to learn Regular Expressions

http://it-ebooks.info/book/920/[^]

Good Luck


这篇关于如何编写正则表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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