需要正则表达式帮助 [英] Needing for regular expression help

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

问题描述

问候朋友,



我需要一些关于正则表达式的帮助,我是新手。

以下是必须遵守的规则:



- 允许使用符号+#$&%ñÑ和空格,它可能位于字段的开头,结尾或中间(任何部分)

- 如果有任何符号或空格,则表达式的任何部分都必须有字母或数字(它不能只是符号)

- 是必填字段。



我在考虑这样的事情:



[A-Za-z0-9Ññ] +



但我不知道如何添加符号部分。

谢谢非常适合你的帮助!

Greetings friends,

I need some help on regular expressions, Im pretty new on this.
Here are the rules it must have:

- Admits symbols +#$&% ñ Ñ and space and it may be at the beginning, end or middle of the field (any part)
- If there is any symbol or space, it must have a letter or number on any part of the expression (it cant be only symbols)
- Is a required field.

I was thinking on something like this:

[A-Za-z0-9Ññ]+

But I dont know hoy to add the symbol part.
Thanks a lot for your help!

推荐答案

&%ñÑ和空间,它可能位于该领域的开始,结束或中间(任何部分)

- 如果有任何符号或空格,则表达式的任何部分都必须有字母或数字(它不能只是符号)

- 是必填字段。



我在考虑这样的事情:



[A-Za-z0-9Ññ] +



但我不知道如何添加符号部分。

非常感谢你的帮助!
&% ñ Ñ and space and it may be at the beginning, end or middle of the field (any part)
- If there is any symbol or space, it must have a letter or number on any part of the expression (it cant be only symbols)
- Is a required field.

I was thinking on something like this:

[A-Za-z0-9Ññ]+

But I dont know hoy to add the symbol part.
Thanks a lot for your help!


这不是一个好的正则表达式问题:你真正想要的是什么do是使用正则表达式来查找字符串是否包含任何特殊字符,然后计算非特殊字符的数量。但你的描述基本上归结为:你可以使用你喜欢的任何角色,但你必须至少有一个非特殊角色(因为你可以在任何地方都有特价,但你需要至少一个非特殊,但你不要''必须有任何特价。)所以使用你有的正则表达式 - 或者更好,使用它:

This is not a "good" regex problem: what you really want to do is use a regex to find if a string contains any "special" characters, then count the number of non-special characters. But your description basically comes down to: you can use any characters you like, but you must have at least one non-special character (because you can have specials anywhere, but you need at least one non-special, but you don''t have to have any specials.) So use the regex you have - or better, use this:
\w+

这是关于相同,但包含更多重音字符。

which is about the same, but includes more accented characters.


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

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