VGMdb - Artist and Composer per track

I'm trying to work on a script to add the artist and composer tags from VGMdb for individual tracks. This information is presented on VGMdb in various ways, but generally looks as follows:

Disc 1

Composed by:
Composer A (1~6, 8~18, 20)
Composer A & Composer B (7)
Composer C (19)

Disc 2

Does anyone have any advice on how to go about this? My main concern is about how to deal with the ~ symbol. For example, how can we convert the track numbers listed as 3~7 to track numbers 3, 4, 5, 6, 7

Thank you!