弹性搜索正则表达式从右边获取最后7位数字 [英] Elastic search regex to get last 7 digits from right
问题描述
在ElasticSearch ,该模式是默认锚定。这意味着,您不能依赖部分匹配,您需要匹配整个字符串和捕获最后连续的7位数字。
使用
。*([0-9] {7})
其中
-
。*
- 将匹配除换行之外的任何0+字符(尽可能多),然后将回溯匹配... -
([0-9] {7})
- 放置到Capture组1中的7位数字。
如果在正则表达式模式中定义了捕获组,Sense插件将返回捕获的值,因此,不需要完成额外的提取工作(或组访问工作)。
I have data indexed in this format 676767 2343423 2344444 32494444. I need a regular expression to pattern anlayser last 7 digits from right. Ex output: 2494444. Pattern which we have tried [0-9]{7} which is not working.
In ElasticSearch, the pattern is anchored by default. That means, you cannot rely on partial matches, you need to match the entire string and capture the last consecutive 7 digits.
Use
.*([0-9]{7})
where
.*
- will match any 0+ chars other than newline (as many as possible) and then will backtrack to match...([0-9]{7})
- 7 digits placed into Capture group 1.
The Sense plug-in returns the captured value if a capturing group is defined in the regular expression pattern, so, no additional extraction work (or group accessing work) needs to be done.
这篇关于弹性搜索正则表达式从右边获取最后7位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!