• Cut and Paste Question
    5 replies, posted
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: [code] "gEApp_BislA": { "artist": "Tuxedo", "songname": "Watch The Dance", "length": 277 }, "7rRNQ_EH4d8": { "artist": "Nekrogoblikon", "songname": "Bells and Whistles", "length": 251 },[/code] 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 :)
Using your input, I used this: [code]z = x:gsub( [["songname": "(.-)", .-"length": (%d+).-}]], function( a, b ) return [["length": ]] .. b .. ",\n\t\t" .. [["songname": "]] .. a .. '"}' end )[/code] To get this: [code] "gEApp_BislA": { "artist": "Tuxedo", "length": 277, "songname": "Watch The Dance"}, "7rRNQ_EH4d8": { "artist": "Nekrogoblikon", "length": 251, "songname": "Bells and Whistles"},[/code] ( Assuming you wanted to do this in-game or something ) You could honestly do it with any Lua console as everything there is vanilla.
[QUOTE=Kogitsune;47376185]Using your input, I used this: [code]z = x:gsub( [["songname": "(.-)", .-"length": (%d+).-}]], function( a, b ) return [["length": ]] .. b .. ",\n\t\t" .. [["songname": "]] .. a .. '"}' end )[/code] To get this: [code] "gEApp_BislA": { "artist": "Tuxedo", "length": 277, "songname": "Watch The Dance"}, "7rRNQ_EH4d8": { "artist": "Nekrogoblikon", "length": 251, "songname": "Bells and Whistles"},[/code] ( Assuming you wanted to do this in-game or something ) You could honestly do it with any Lua console as everything there is vanilla.[/QUOTE] I was aiming more for using Notepad++ :P
regex
[QUOTE=_Divine;47376316]regex[/QUOTE] Yeah, I saw something that mentioned regex but I didn't understand how it worked or what to do xD
Use this: Find: ((.*)\"song(.*))\n((.*)(\"length\")(.*)) Replace: \4,\n\1 To remove the comma after the new 'songname' lines, run this: Find: (.*)(\"songname\")(.*)(,) Replace: \1\2\3 [B]Edit:[/B] Just run this once to avoid doing two separate ones: Find: (.*)(\"songname\")(.*)(,)\n((.*)(\"length\")(.*)) Replace: \5,\n\1\2\3
Sorry, you need to Log In to post a reply to this thread.