2

I'm cleaning out a a .txt file with all the pantone colors for use in a script

What I want is this:

HEX:FEDDOO YellowC 254 221 0

and what I currently have in my textfile is this:

Yellow C HEX:FEDD00 254 221 0

So i have a name for the color, a hex number and the RGB numbers.

The RGB blocks are always the last 3 letters/words and the hex number is always the 4th word in the line, the name of the color is sometimes made up of 1/2 or 3 blocks of text Yellow C Blue 0821 C ...

First, I should be able to join the color name in one word (so Yellow C to YellowC; Blue 0821 C to Blue0821C; etc.

So, in every line i'll have 5 blocks.

Then, the hex number should go in the beginning of the line instead of being the second "word". (--> block one becomes block 2 and block 2 becomes block 1)

The reason I want it like that is that I already made a RAL chart with every value in that order, so I should be able to create the pantone chart in the same manner so I can use the same script to read those values.

Thanks in advance!

1 Answer 1

0

Notepad++ can do this for you, but it will be a 3-step replacement. Open Notepad++'s Replace dialog (Search > Replace...) and make sure Search Mode is set to "Regular expression". Then perform the following 3 searches:

  1. Search for ^(.*?) (HEX:.{6}) (\d+) (\d+) (\d+)$ and replace it with $2|$1|$3|$4|$5. This will put your components in the correct order and will replace spaces with the pipe symbol. After running it, your example will look like this: HEX:FEDD00|Yellow C|254|221|0.
  2. Then search for (a space) and replace it with nothing. This will eliminate all remaining spaces (which should be just those spaces you don't want in the color name. After running it, your example will look like this: HEX:FEDD00|YellowC|254|221|0.
  3. Finally replace \| with (a space). This will convert the pipe symbols back to spaces. After running it, your example will look like this: HEX:FEDD00 YellowC 254 221 0.
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .