Cut and Paste Question

Not sure if this is meant to be in the dev seciton but I have a question that I can’t find an understandable answer.
I was wondering if there was any way to cut and paste large sections of text regardless of there being variables involved.
For example:


    "gEApp_BislA": {
        "artist": "Tuxedo",
        "songname": "Watch The Dance",
        "length": 277
    },
    "7rRNQ_EH4d8": {
        "artist": "Nekrogoblikon",
        "songname": "Bells and Whistles",
        "length": 251
    },

How would I cut and paste “length”: 251 to before “songname”: “Bells and Whistles” but with all instances of length without changing each variable?
Thanks for any help :slight_smile:

Using your input, I used this:


z = x:gsub( [["songname": "(.-)",
.-"length": (%d+).-}]], function( a, b )
	return [["length": ]] .. b .. ",
		" .. [["songname": "]] .. a .. '"}'
end )

To get this:


	"gEApp_BislA": {
		"artist": "Tuxedo",
		"length": 277,
		"songname": "Watch The Dance"},
	"7rRNQ_EH4d8": {
		"artist": "Nekrogoblikon",
		"length": 251,
		"songname": "Bells and Whistles"},

( Assuming you wanted to do this in-game or something )

You could honestly do it with any Lua console as everything there is vanilla.

I was aiming more for using Notepad++ :stuck_out_tongue:

regex

Yeah, I saw something that mentioned regex but I didn’t understand how it worked or what to do xD

Use this:
Find: ((.)"song(.))
((.)(“length”)(.))
Replace: \4,
\1

To remove the comma after the new ‘songname’ lines, run this:
Find: (.)(“songname”)(.)(,)
Replace: \1\2\3

Edit: Just run this once to avoid doing two separate ones:
Find: (.)(“songname”)(.)(,)
((.)(“length”)(.))
Replace: \5,
\1\2\3