sholsapp
sholsapp

Reputation: 16070

Uninterpreted strings in YAML

Is there a way to have uninterpreted strings within a YAML file? My goal is to have regular expressions that contain 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?

Upvotes: 15

Views: 17697

Answers (2)

Amber
Amber

Reputation: 526503

Try using literal scalar syntax?

Upvotes: 10

sholsapp
sholsapp

Reputation: 16070

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

E.g.,

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

Works.

Upvotes: 17

Related Questions