#1 2010-03-18 05:36

abba77
Member
Registered: 2010-03-18
Posts: 3

Removing color codes in $[0369CF] form

Hi,

What an awesome application!

I was wondering if you could help with a filter setting. I have a bunch of files which have control codes for colors. I would like to strip them out. Here is the problem: there are 246 combinations. The control codes are listed towards the bottom of  this page: http://tutorials.tm-creative.org/genera … t_colours/

The control code is in the format of $### where each of the # is one character that can be 0,3,6,9,C or F.
I was trying to add a filter to remove in the form of $[0369CF][0369CF][0369CF] where each square bracket representing one character. Of course that didnt work.

e.g. a file named "$000Asco $600vs. $900Marcster $C00third $F00Combat.gbx" I would like to show up as "Asco vs. Marcster third Combat.gbx"

Any suggestions on how to handle this without adding all 246 possible codes.

Thanks.

Last edited by abba77 (2010-03-18 05:37)

Offline

#2 2010-03-18 07:14

abba77
Member
Registered: 2010-03-18
Posts: 3

Re: Removing color codes in $[0369CF] form

digging around a little, i found a regex phrase which i trial and errored with.

i used this as my regex and replace it with a blank:

\$[0-9|A-Z][0-9|A-Z][0-9|A-Z]

I found some files had A, N or M also, so i figured to use them all...replace the $ and any 3 characters after it.

seemed to work, but any better suggestions for next time?

Btw, what does the first \ do? If I did not user the \ before the $, it did not work.

Last edited by abba77 (2010-03-18 07:27)

Offline

#3 2010-03-18 08:01

SafetyCar
Senior Member
Registered: 2008-04-28
Posts: 446
Website

Re: Removing color codes in $[0369CF] form

\$[0369CF]{3}

This means, a text that contains a $ followed by 3 of the characters between [brackets]

The \ is necessary because the $ alone means enf of text, and to skip that meaning we put that bar


One thing more: This [0-9|A-Z] means: any char betwen 0 and 9 + the symbol "|" + any char between A and Z
So the way you did it could match $|||. [0-9A-Z] is what you wanted to do  wink


If this software has helped you, consider getting your pro version. :)

Offline

#4 2010-03-18 11:01

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Removing color codes in $[0369CF] form

Hi abba, welcome to the community!

SafetyCar has already provide the right solution:
\$[0369CF]{3}
\$[0-9A-Z]{3}


If someone wants the shortest RegEx, try this:
\$\w{3}





-------------------------

For all others, not so familiar with ReNamer, here are some more infos what's about:

FROM:
$000Asco $600vs. $900Marcster $C00third $F00Combat.gbx
TO:
Asco vs. Marcster third Combat.gbx

Add rule RegEx
Expression: "\$\w{3}"
Replace:  ""
[  ] case-sensitive
[X] skip extension


Explanation:
Don't use this " " -quotes from my explanation. They are only for clarification.
\$ ==> escaped regex meta char $ to find literal char $
\w ==> one piece of an alphanumeric character, including an underscore (_)
{3} ==> Quantifier: {n} = exactly n times of the preceding expression

So "\$\w{3}" will match the sign $ followed by three pieces of any kind
from all digits [0-9] or chars [A-Za-z] (incl. the underscore (_))
like e.g. "$000", "$600", "$900", "$C00", "$F00C", "$abc", ...
and 'Replace:  "" '  will replace with nothing, meaning deleting what is found by this regex expression.

See the WIKI for more about this:
=> http://www.den4b.com/wiki/ReNamer:Rules for more about using Rules and
=> http://www.den4b.com/wiki/ReNamer:Regular_Expressions for more about the RegEx Syntax.

More Help
* online tester:
- http://rereplace.com/
- http://www.regextester.com/
- http://www.regexlib.com/RETester.aspx

* online help:
- www.regular-expressions.info
- www.regexlib.com/
- www.regexlib.com/CheatSheet.aspx


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2010-03-18 15:03

abba77
Member
Registered: 2010-03-18
Posts: 3

Re: Removing color codes in $[0369CF] form

thanks a  lot to both. I'm not a technical person by any means but can usually figure something out by editing existing solutions. The regex links to guides and turorials was making my head spin. Appreciate the quick and understandable quide.

Offline

Board footer

Powered by FluxBB