简体   繁体   English

我在哪里放置模式以允许在正则表达式中使用点?

[英]Where do I place the pattern to allow dot in a regular expression?

I'm not the greatest when it comes to Regex.在 Regex 方面,我不是最棒的。 I found one that fullfills my requirements, but I also need it to allow dot (only one and in the end of a sentence).我找到了一个可以满足我的要求的,但我还需要它允许点(只有一个并且在句末)。

The regex is this one: /^[a-zA-ZÀ-ÿñÑ]+(\s*[a-zA-ZÀ-ÿñÑ]*)*[a-zA-ZÀ-ÿñÑ]+$/正则表达式是这个: /^[a-zA-ZÀ-ÿñÑ]+(\s*[a-zA-ZÀ-ÿñÑ]*)*[a-zA-ZÀ-ÿñÑ]+$/

If possible, could someone send me the same regex, but with the mentioned conditions?如果可能的话,有人可以给我发送相同的正则表达式,但要满足上述条件吗?

Regards,问候,

Cristian.克里斯蒂安。

Change this:改变这个:

/^[a-zA-ZÀ-ÿ\u00f1\u00d1]+(\s*[a-zA-ZÀ-ÿ\u00f1\u00d1]*)*[a-zA-ZÀ-ÿ\u00f1\u00d1]+$/

To this to allow an optional dot at the end of the sentence:为此,允许在句子末尾使用一个可选的点:

/^[a-zA-ZÀ-ÿ\u00f1\u00d1]+(\s*[a-zA-ZÀ-ÿ\u00f1\u00d1]*)*[a-zA-ZÀ-ÿ\u00f1\u00d1]+\.?$/

Explanation: \.?解释: \.? is an escaped dot, the question mark makes it optional.是转义点,问号使其可选。

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

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