开发者

match chars, numeric and special chars within a pattern

开发者 https://www.devze.com 2023-03-25 21:09 出处:网络
within a string i could have the following: this i开发者_如何转开发s a string ::foo:bar:: ::baz:123abc:: ::bäz:üéü:: ::#$%%:4/4::

within a string i could have the following:

this i开发者_如何转开发s a string ::foo:bar:: ::baz:123abc:: ::bäz:üéü:: ::#$%%:4/4::

how can i get all parts with starts with :: and ends with :: and match what is in between. within those colons there are key, value pairs i need to filter out of the string.

if there wouldn't be special chars i the regex would look like this:

r'::([a-z0-9]+):([a-z0-9]+)::'

i could list those special chars manually but i don't think thats the right way to do this.

thx


With not-colon:

 r'::([^:]+):([^:]+)::'


First you should mention the regex flavor/tool you'd like to use, but generally:

r'::([^:]+)::

Should capture the special chars as well.

HTH

0

精彩评论

暂无评论...
验证码 换一张
取 消