Ulysses

General => Off-Topic => Topic started by: Bryantdl7 on September 22, 2015, 10:23:24 AM

Title: Help with bulk deletion
Post by: Bryantdl7 on September 22, 2015, 10:23:24 AM
So I am trying to find a way to delete all strings that contain "new" in the script structure below
Code: [Select]
"STEAM_0:0"
{
"name" "mX"
"deny"
{
}
"allow"
{
}
"group" "new"
}
However, as you can tell I am working with steam ID's so it is not as simple as imputting it into ms word and doing a replace action, I want to delete everything I put inside that code box above. I was wondering if anyone knows of a program that can delete the entire string if it contains a certain variable, such as "group"   "new"
I am cleaning out my users.txt file as it has over 41 thousand lines, and i want to quickly delete everyone from the database while saving my staff from being deleted.

If I confused you guys I can try and explain it better
Title: Re: Help with bulk deletion
Post by: roastchicken on September 23, 2015, 12:12:32 PM
Use notepad++'s replace feature. It accepts regex expressions and you can just replace it with nothing.

Code: [Select]
"STEAM_0:(0|1):\d+"\s\n{\n\s matches a steamid followed by the first brace and some spaces and newlines
Code: [Select]
"deny"\s\n\s{\n\s\}\n\s matches "deny" followed by some spaces, new lines, and braces
Code: [Select]
"allow"\s\n\s{\n\s\}\n\s matches "allow" followed by some spaces, new lines, and braces
Code: [Select]
"name"\s".+\n\s matches "name" and someones name, followed by some spaces and new lines
Code: [Select]
"group"\s"new"\n\}\n matches "group" and "new", followed by some spaces and new lines and the closing brace and then another newline

all put together:
Code: [Select]
"STEAM_0:(0|1):\d+"\s\n{\n\s"deny"\s\n\s{\n\s\}\n\s"allow"\s\n\s{\n\s\}\n\s"name"\s".+\n\s"group"\s".+"\n\}\n
Of course because of the genius of users.txt, the deny, allow, and name fields can be in any order. Hip hurray! (I'm sure there must be a good reason for this, and I'm curious what that reason is. It's just also pretty irritating.)

Just go ahead and re-order those three elements (total of six possible combinations) and you should be able to get them all.
Title: Re: Help with bulk deletion
Post by: Bryantdl7 on September 24, 2015, 07:02:25 AM
Thank you so much! It worked perfectly! users.txt 407kb down to 41 kb!
+Rep
Title: Re: Help with bulk deletion
Post by: Aaron113 on September 24, 2015, 09:54:54 AM
Use notepad++'s replace feature. It accepts regex expressions and you can just replace it with nothing.

I really need to learn more about regex haha, looks powerful.
Title: Re: Help with bulk deletion
Post by: roastchicken on September 24, 2015, 03:10:35 PM
Yea I've never used it before, but it seemed like it would work for this. I just used an online regex tester that also had a regex cheatsheet. It was much easier than I expected.
Title: Re: Help with bulk deletion
Post by: JamminR on September 25, 2015, 08:10:44 AM
RegEx is awesome and used in so many different coding/scripting languages for string manipulation it's incredible.
I too never learned even 1% of what it can do.
RoastChicken, though I'm sure we could all find one or two using Google, you should share your link that helped you.
Title: Re: Help with bulk deletion
Post by: roastchicken on September 25, 2015, 10:31:54 PM
The site I used was https://regex101.com/ (https://regex101.com/), but as you said there are tons of regex testers out there. I like  this site in particular because it explains what each character in your command does, so you can find mistakes more easily.