html tool

显示标签为“正则”的博文。显示所有博文
显示标签为“正则”的博文。显示所有博文

2020年9月10日星期四

转:正则表达匹配 东欧语言特殊字符

 

正则表达匹配 东欧语言特殊字符

地址: https://www.thinbug.com/q/1922097

我一直在使用的字符类如下:

[\wÀ-Üà-øoù-ÿŒœ]。它所覆盖的字符集仅比法语略大,但不包括东欧和斯堪的纳维亚的变音符号和与法语无关的字母。我发现这是简洁与排他性之间的不错折衷。

要匹配/验证完整句子,我使用以下表达式: [\w\s.,!?:;&#%’'"()«»À-Üà-øoù-ÿŒœ],其中包括标点符号和法式引号。

2018年11月29日星期四

elasticsearch 使用正则查询



https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-regexp-query.html

http://cwiki.apachecn.org/pages/viewpage.action?pageId=4260873

标准字符都支持,比如如下就ok

curl -XGET "/_search/ -d'
{
    "query": {
        "regexp":{
            "node_name": "cascade-node-[12][2-9]{1,2}"
        }
    }
}'

查了一下官方帮助分组,定位符,逻辑判断都ok,lucene应该是很内置了正则引擎,
如下:

Grouping
Parentheses "()" can be used to form sub-patterns. The quantity operators listed above operate on the shortest previous pattern, which can be a group. For string "ababab":
(ab)+       # match
ab(ab)+     # match
(..)+       # match
(...)+      # no match
(ab)*       # match
abab(ab)?   # match
ab(ab)?     # no match
(ab){3}     # match
(ab){1,2}   # no match
Alternation
The pipe symbol "|" acts as an OR operator. The match will succeed if the pattern on either the left-hand side OR the right-hand side matches. The alternation applies to the longest pattern, not the shortest. For string "aabb":
aabb|bbaa   # match
aacc|bb     # no match
aa(cc|bb)   # match
a+|b+       # no match
a+b+|b+a+   # match
a+(b|c)+    # match
Character classes
Ranges of potential characters may be represented as character classes by enclosing them in square brackets "[]". A leading ^ negates the character class. The allowed forms are:
[abc]   # 'a' or 'b' or 'c'
[a-c]   # 'a' or 'b' or 'c'
[-abc]  # '-' or 'a' or 'b' or 'c'
[abc\-] # '-' or 'a' or 'b' or 'c'
[^abc]  # any character except 'a' or 'b' or 'c'
[^a-c]  # any character except 'a' or 'b' or 'c'
[^-abc]  # any character except '-' or 'a' or 'b' or 'c'
[^abc\-] # any character except '-' or 'a' or 'b' or 'c'
Note that the dash "-" indicates a range of characters, unless it is the first character or if it is escaped with a backslash.
For string "abcd":
ab[cd]+     # match
[a-d]+      # match
[^a-d]+     # no match

2018年9月27日星期四

bat 正则表达



https://www.jb51.net/article/17848.htm

问题:
bat中如何使用正则
解答:
findstr 正则表达 文件名称

[popexizhi:

5.findstr "[abcezy]" 2.txt 
从文件2.txt中查找包括a b c e z y字母的字符串或行 
==================== 

6.findstr "[a-fl-z]" 2.txt 
从文件2.txt中查找小写字符a-f l-z的字符串,但不包含g h I j k这几个字母。 
==================== 

7.findstr "M[abc][hig]Y" 2.txt 
从文件2.txt中可以匹配 MahY , MbiY, MahY等….. 
==================== 

8. ^和$符号的应用 
^ 表示行首,"^step"仅匹配 "step hello world"中的第一个单词 
$ 表示行尾,"step$"仅匹配 "hello world step"中最后一个单词 
==================== 

9.finstr "[^0-9]" 2.txt 
如果是纯数字的字符串或者行便过滤掉,例如2323423423 这样的字符串,如果是345hh888这样的形式就不成了。 
==================== 
]

2017年8月21日星期一

regexp rlike not rlike

add:http://www.cnblogs.com/xyxxs/p/4748708.html

问题 : sql如何使用正则取反

回答:
不使用正则
 select * from a where id not like '_a%';

使用正则单字符
select * from a where id regexp '[0-9][^a]\..*';

使用正则字符串
??