Parsing file content

I’m trying to check some sections of a yaml file. Usually using key works fine for one line entries like
ssl_protocols: [“TLSv1.2”]

Q: key “ssl_protocols” of file "config.yaml"
A: [“TLSv1.2”]
T: 4841

If the value contains more than one entry it goes fancy:

ssl_cipher_suites_browser:
- 'ECDHE-RSA-AES256-GCM-SHA384'
- 'ECDHE-ECDSA-AES256-GCM-SHA384'
- 'ECDHE-RSA-AES128-GCM-SHA256'
- 'ECDHE-ECDSA-AES128-GCM-SHA256'
- 'ECDHE-RSA-CHACHA20-POLY1305'
- 'ECDHE-ECDSA-CHACHA20-POLY1305'
- 'DHE-RSA-AES256-GCM-SHA384'
- 'DHE-RSA-AES128-GCM-SHA256'

Key delivers a empty value in this case. Something like
Q: (next lines of it) of lines whose (it contains “ssl_cipher_suites_browser:”) of file "config.yaml"
A: - 'ECDHE-RSA-AES256-GCM-SHA384’
T: 462

returns only the first line. I can imagine something like “preceding text of last “’” of …” but actual I’m running out of ideas.

I put the sample in code tags - does the spacing and hyphenation look correct compared to the sample now?

This problem looks similar to a challenge I posted a couple years back - determining paragraphs/stanzas from a text file, at Relevance Challenge December 2019 BONUS: Parsing Paragraphs (answer provided)

There are several solutions there. I’m afraid they’re all fairly long, but I think at least a couple of them should work for this case. I should be able to look at this later today if those don’t solve it, let me know.

1 Like

Thanks, yes, the sample looks correct. I will check the examples, doesn’t look so easy :slight_smile:

Maybe we will just check for lines starting with “- '” and regex for for the ciphers. I will discuss with my colleague.