简体   繁体   English

正则表达式RegEx,用于验证php中的复杂字符串

[英]Regular Expression, RegEx, for validation of complex string in php

Hey I am trying to get a php RegEx for a string with following valid characters: 嘿,我正在尝试为包含以下有效字符的字符串获取php RegEx:

Any [a-zA-Z]* (aZ) strings are allowed, and than numbers with the format: /xxx, where xxx stands for numbers as follows: 000-032 and 035 and 092. And these strings and \\xxx sequences can be concatenated in any way, as many times as we want, fore example: 允许使用任何[a-zA-Z] *(aZ)字符串,并且不允许使用格式为/ xxx的数字,其中xxx代表以下数字:000-032和035和092。这些字符串和\\ xxx序列可以以任意方式进行连接,次数不限,例如:

"STring\\032with\\032a\\032\\032\\backslash\\032\\092and\\010a\\035newLine" “ STRING \\ 032with \\ 032a \\ 032 \\ 032 \\反斜杠\\ 032 \\ 092and \\ 010a \\ 035newLine”

What I got so far is this RegEx: [[az]*\\\\0([0-2][0-9]|3[0-2]|35|92)]* 到目前为止,我得到的是此RegEx:[[az] * \\\\ 0([0-2] [0-9] | 3 [0-2] | 35 | 92)] *

But it seems to only recognize strings with a 'string part' concatonated with a 'backslash part' : "exampleString\\032" and nothething afterwards 但是它似乎只能识别带有'反斜杠部分'的'字符串部分'的字符串:“ exampleString \\ 032”,之后什么也没有

PLUS can I somehow make a REGEX where the string characters can be of a specific alphabet? 另外,我可以以某种方式制作一个正则表达式,其中字符串字符可以是特定字母吗? Like lets say German or Czech? 像是说德语还是捷克语?

I hope this will do the trick : 我希望这可以解决问题:

^((([a-zA-Z])\\?)*(((0[0-2][0-9])|(03[0-2])|(035)|(092))\\?)*)+$

Successfully tested here. 在这里成功测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM