开发者

Uninterpreted strings in YAML

开发者 https://www.devze.com 2023-03-24 11:45 出处:网络
Is there a way to have uninterpreted strings within a YAML file?My goal is to have regular expressions that 开发者_如何学Gocontain certain escape sequences like \\w.Currently, Python\'s YAML complains

Is there a way to have uninterpreted strings within a YAML file? My goal is to have regular expressions that 开发者_如何学Gocontain certain escape sequences like \w. Currently, Python's YAML complains: found unknown escape character 'w'.

I know I could escape them, but this is going to obfuscate the actual regular expression. Any way around this?


Appears that using single quotes doesn't interpret the escaped characters.

E.g.,

key1: [ 'tron' ]
key2: [ 'not/escaped/[\w-]*/.*' ]

Works.


Try using literal scalar syntax?

0

精彩评论

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