我有以下字符串:
"
key1: fkdfjdkfkdfjkdfkjdkfjdfkjdfkdjfkdjfkdfjkdfdkfjkdf
key2: dskfjdfjdkfkjdfkdjfkdfjdfkdfkdkjfkdfjkdf
key3: sdfsdfasdfadfs
asdfadsfsdfasdfadsfdf
key4: sdfjdsfhhdjfhsdjfsdfh
skdfjdsjkfjds
"
什么是仅捕获键值的有效正则表达式?
答案 0 :(得分:2)
以下正则表达式可以解决您的问题,前提是您使用的是PCRE引擎:
/(?:key\d+: )(.*?)(?=\nkey\d:|$)/gs
说明: