简体   繁体   English

匹配确切单词的正则表达式

[英]Regex in matching exact word

I am trying to match an exact word before last dot and after last dot it should be number.我试图在最后一个点之前匹配一个确切的单词,在最后一个点之后它应该是数字。

(\W*((?i)rocket\.jhagsc\.djagsh(?-i)(.*(?=\.).))\W*)((.*(?=\.).)(\d+))

Example:例子:

rocket.jhagsc.djagsh.465465

It should match.它应该匹配。

I would phrase this as:我将其表述为:

\brocket.jhagsc.djagsh[^.]*\.(?!.*\.)\d.*$

Here is an explanation of the regex pattern:以下是正则表达式模式的解释:

\brocket.jhagsc.djagsh   match your exact word
[^.]*                    then match zero or more non dots (i.e. allow no dots)
\.                       match the final dot
(?!.*\.)                 then assert that no more dots occur in the string
\d                       match a single digit immediately after the final dot
.*                       consume the remainder of the string
$                        end of the string

Demo演示

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

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