RegEx字符串模式 [英] RegEx string pattern

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

问题描述





有人可以帮我找到这种格式的字符串的RegEx模式





Hi,

Can someone help me to find RegEx pattern for this format of string


/AC011/20_ABC/AEEE/ACD_AEEE_Opw21_1
123
 
1.1.1.11.0-11





提前谢谢,



Thanks in advance,

推荐答案

正则表达式可能是错误的工具,除非你试图将该字符串作为模式匹配:

斜线,后跟两个大写Alpha,三个数字,然后是另一个斜线,然后是......

如果你想要找到一个确切的字符串,然后使用字符串比较 - 它更容易阅读更简单!

如果你想匹配一个模式,那么你需要给我们一点更多信息关于什么是和不允许的地方 - 以及你需要将其分解为匹配组。获取 Expresso [ ^ ] - 它是免费的,它会检查并生成正则表达式。



并尝试开始于:

Regex is probably the wrong tool, unless you are trying to match that string as a pattern:
"A slash, followed by two uppercase Alpha, and three digits, then a other slash, followed by ..."
If you want to find an exact string, then use string comparison instead - it''s a lot easier and a lot simpler to read!
If you want to match a pattern, then you need to give us a bit more info on what is and isn''t allowed where - and what you need to break it into as far as match groups are concerned. Get a copy of Expresso [^] - it''s free, and it examines and generates Regular expressions.

And try starting with:
/(?<id>[A-Z]{2}\d{3})/(?<productcode>\d{2}_[A-Z]{3})</productcode></id>

这可能涵盖前两个字段。

Which may cover the first two fields.


这篇关于RegEx字符串模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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