I'm trying to match a pattern and then pull the following information to create a file using that variable.
Example (my data may look like either of the 2 examples)
"headers": {
"content-type": "application/octet-stream;\r\n\tname=\"I may have long file names - With lots of spaces.zip\"",
"content-transfer-encoding": "base64",
"content-disposition": "attachment;\r\n\tfilename=\"I may have long file names - With lots of spaces.zip\""
or
"headers": {
"content-type": "application/octet-stream",
"content-transfer-encoding": "base64",
"content-disposition": "attachment; filename=tiny.exe"
Basically I'm trying to create a new file named as the filename. So example 1 has a really long filename with spaces and hypens, example 2 has a short filename. Example 1 is identified by 'tfilename' and example 2 'filename' .
Obviously I don't need the double quotes.
Can anyone assist with this please?
Thanks!
I would consider using a language that can parse the JSON and manipulate the data. Here's some ruby (and shell)