正则表达式模式匹配给定的示例单词 [英] Regex pattern to match given example word
本文介绍了正则表达式模式匹配给定的示例单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
HI,
我需要一个正则表达式模式来匹配十进制数之前的字符串。我需要输出完全如下例所示
样本输出:
text.33
样本.51
谢谢!
I need a regex pattern to match a string before decimal number.I need the output exactly as below example
sample outputs:
text.33
sample.51
Thank You!
推荐答案
如果你想要以下样本输出的正则表达式模式:
text.45
example.90 >
value.46
然后尝试:
If you want regex pattern for the following sample outputs:
text.45
example.90
value.46
then try:
\b[a-zA-Z]*[.][\d][\d]\b
否则,如果你只需要这些字母:
text
示例
值
然后尝试:
Else if you only want those alphabets:
text
example
value
then try:
\b[a-zA-Z]*(?=[.][\d][\d]\b)
++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++ b $ b
+++++++++++++++++++++++++++++++++++++++++
[amended upon re-understanding]
\b[a-zA-Z]+[.][\d][\d]\b
实际上只需将'*'更改为'+'
actually just need to change the '*' to '+'
尝试:
Try:
[^\d]*\d+
这篇关于正则表达式模式匹配给定的示例单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文