Convert raw string to HEX colors

The idea is to send a color in exadecimal through a terminal (the terminal is from blynk, that is, I receive it in String format), for example 00AACC, but through the terminal I can send data that is not hex, what I want is that only if the string measures 6 characters (it already works for me) and only contains the characters 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F I saved it in the configuration color string

if(0 <= TEMP_2.length() && TEMP_2.length() <= 6){VAR_X01B = TEMP_2;)

the String TEMP_2 saves the input, and the String VAR_X01B, saves the output

how could i do it?

Hello arixtoteles09
Post your sketch, well formated, with comments and in so called code tags "</>" and schematic to see how we can help.

Have a nice day and enjoy coding in C++.

I don't see it as necessary, but here it is

#define BLYNK_TEMPLATE_ID "*****"
#define BLYNK_DEVICE_NAME "*****"

#define LED_BUILTIN 15

#define BLYNK_FIRMWARE_VERSION        "0.1.0"
#define BLYNK_PRINT Serial
#define APP_DEBUG

#include "BlynkEdgent.h"
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <HTTPClient.h>
#include <WebServer.h>

WiFiUDP     WIFI_udp;
NTPClient   NTP_client(WIFI_udp, "europe.pool.ntp.org", 3600, 60000);
HTTPClient  HTTP_client;    
WebServer   HTTP_server(80);

int    NTP_h    = 0         ;//hora actual: hora
int    NTP_m    = 0         ;//hora actual: minuto
                            
int    VAR_V00A = 0         ;//device 0: Minute day
bool   VAR_V01A = false     ;//device 0: Status led
String VAR_V02A = ""        ;//device 0: terminal

int    VAR_X00A = 0         ;//device 1: Time mode
int    VAR_X00B = 0         ;//device 1: Time start
int    VAR_X00C = 0         ;//device 1: Time end

bool   VAR_X01A = false     ;//device 2: RGB enable
String VAR_X01B = "000000"  ;//device 2: RGB color HEX

void setup()
{
  Serial.begin(115200);
  delay(5000);
  BlynkEdgent.begin();
  NTP_client.begin();

  pinMode(LED_BUILTIN, OUTPUT);
  
  HTTP_server.on("/*****/V00A", HTTP_VAR_V00A);//VAR_V00A web asignation
  HTTP_server.on("/*****/V01A", HTTP_VAR_V01A);//VAR_V01A web asignation
  HTTP_server.on("/*****/X00A", HTTP_VAR_X00A);//VAR_X00A web asignation
  HTTP_server.on("/*****/X00B", HTTP_VAR_X00B);//VAR_X00B web asignation
  HTTP_server.on("/*****/X00C", HTTP_VAR_X00C);//VAR_X00C web asignation
  HTTP_server.on("/*****/X01A", HTTP_VAR_X01A);//VAR_X01A web asignation
  HTTP_server.on("/*****/X01B", HTTP_VAR_X01B);//VAR_X01B web asignation
  
  HTTP_server.on("/",                                     HTTP_VAR_E00A);//Error Asignation
  HTTP_server.onNotFound(                                 HTTP_VAR_E01A);//Error Asignation
  
  HTTP_server.begin();
}

void loop() {
  BlynkEdgent.run();
  NTP_client.update();
  
  NTP_h = NTP_client.getHours();
  NTP_m = NTP_client.getMinutes();
  VAR_V00A = (NTP_h * 60) + NTP_m;
  Blynk.virtualWrite(V0, VAR_V00A);
  
  VAR_V01A = !VAR_V01A;
  Blynk.virtualWrite(V1, VAR_V01A);
  digitalWrite(LED_BUILTIN, VAR_V01A);

  HTTP_server.handleClient();//Wait for client petitions
  delay(1000);
}

BLYNK_WRITE(V0){
  VAR_V00A = param.asInt();//value reception
}

BLYNK_WRITE(V2){
  VAR_V02A = ""; //value reset
  VAR_V02A = param.asString(); //value reception
  String TEMP_1 = "";//Comand Var
  String TEMP_2 = "";//Value var (String)
  int    TEMP_3 = 0;//Value var (Int)
  String TEMP_4 = "";//RGB var (Formatted)
  for(int i = 0; i <= 4; i++){TEMP_1 = TEMP_1 + String(VAR_V02A.charAt(i));}//Comand extraction
  for(int i = 5; i < VAR_V02A.length(); i++){TEMP_2 = TEMP_2 + String(VAR_V02A.charAt(i));}//Value extraction
  TEMP_3 = TEMP_2.toInt();//Value conversion to int
  
  //Terminal value return----------------------------------------------------------------------------------------------------------//
  
  if(TEMP_1 == "V00A?"){Blynk.virtualWrite(V2, String(VAR_V00A));}//terminal: returns VAR_V00A
  if(TEMP_1 == "V01A?"){Blynk.virtualWrite(V2, String(VAR_V01A));}//terminal: returns VAR_V01A
  
  if(TEMP_1 == "X00A?"){Blynk.virtualWrite(V2, String(VAR_X00A));}//terminal: returns VAR_X00A
  if(TEMP_1 == "X00B?"){Blynk.virtualWrite(V2, String(VAR_X00B));}//terminal: returns VAR_X00B
  if(TEMP_1 == "X00C?"){Blynk.virtualWrite(V2, String(VAR_X00C));}//terminal: returns VAR_X00C
  
  if(TEMP_1 == "X01A?"){Blynk.virtualWrite(V2, String(VAR_X01A));}//terminal: returns VAR_X01A
  if(TEMP_1 == "X01B?"){Blynk.virtualWrite(V2, String(VAR_X01B));}//terminal: returns VAR_X01B
  
  //Terminal asignations-----------------------------------------------------------------------------------------------------------//
  
  if(TEMP_1 == "V00A!" && 0 <= TEMP_3 && TEMP_3 <= 1440               ){VAR_V00A = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_V00A");}
  if(TEMP_1 == "V01A!" && 0 <= TEMP_3 && TEMP_3 <= 1                  ){VAR_V01A = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_V01A");}
  
  if(TEMP_1 == "X00A!" && 0 <= TEMP_3 && TEMP_3 <= 2                  ){VAR_X00A = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_X00A");}
  if(TEMP_1 == "X00B!" && 0 <= TEMP_3 && TEMP_3 <= 1440               ){VAR_X00B = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_X00B");}
  if(TEMP_1 == "X00C!" && 0 <= TEMP_3 && TEMP_3 <= 1440               ){VAR_X00C = TEMP_3;Blynk.virtualWrite(V2, "Setes VAR_X00C");}
  
  if(TEMP_1 == "X01A!" && 0 <= TEMP_3 && TEMP_3 <= 1                  ){VAR_X01A = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_X01A");}
  if(TEMP_1 == "X01B!" && 0 <= TEMP_2.length() && TEMP_2.length() <= 6){VAR_X01B = TEMP_3;Blynk.virtualWrite(V2, "Seted VAR_X01B");}
}

void HTTP_VAR_E00A(){HTTP_server.send(404, "text/plain", "Utiliza una clave valida");}
void HTTP_VAR_E01A(){HTTP_server.send(404, "text/plain", "Utiliza una clave valida");}
void HTTP_VAR_V00A(){HTTP_server.send(200, "text/plain", String(VAR_V00A));}
void HTTP_VAR_V01A(){HTTP_server.send(200, "text/plain", String(VAR_V01A));}
void HTTP_VAR_X00A(){HTTP_server.send(200, "text/plain", String(VAR_X00A));}
void HTTP_VAR_X00B(){HTTP_server.send(200, "text/plain", String(VAR_X00B));}
void HTTP_VAR_X00C(){HTTP_server.send(200, "text/plain", String(VAR_X00C));}
void HTTP_VAR_X01A(){HTTP_server.send(200, "text/plain", String(VAR_X01A));}
void HTTP_VAR_X01B(){HTTP_server.send(200, "text/plain", String(VAR_X01B));}

the code is stored in an esp32 that is used to domotize a series of esp8266 (or tries to)

me too

Have a nice day and enjoy coding in C++.

What?

You could use strtol and check afterwards whether six characters have been parsed. For example,

String s {"012345"};

char const* p {s.c_str()};
char* q {const_cast<char*>(p)};
long value {strtol(p, &q, 16)};
if (q - p == 6) {
  Serial.println(value);  // Or use the first six characters of `s`.
}

I do not understand anything...

Well, I have already made a function to verify that it is correct:

bool IsRGB(String InRGB_){
  if(InRGB_.length() == 6){}else{return false;}
  for(int i = 0; i <= 5; i++){
    if(('0' <= InRGB_.charAt(i) && InRGB_.charAt(i) <= '9') || ('A' <= InRGB_.charAt(i) && InRGB_.charAt(i) <= 'F')){}else{return false;}
  }
  return true;
}

the second part of the problem is to go from the input color in HEX (0xFFFFFF) to the colors in rgb int (255, 255, 255), I don't have the slightest idea how to do it, any ideas?

and thanks to these variables and it worked, I can convert the colors in HEX to 3 int from 0 to 255

int    RGB_R    = 0        ;
int    RGB_G    = 0        ;
int    RGB_B    = 0        ;

String VAR_X01B = "000000";

void MASTER_RgbUpdate(){
  char RGB_r[3];
  char RGB_g[3];
  char RGB_b[3];

  String(String(VAR_X01B.charAt(0)+String(VAR_X01B.charAt(1)))).toCharArray(RGB_r, 3);
  String(String(VAR_X01B.charAt(2)+String(VAR_X01B.charAt(3)))).toCharArray(RGB_g, 3);
  String(String(VAR_X01B.charAt(4)+String(VAR_X01B.charAt(5)))).toCharArray(RGB_b, 3);
  
  RGB_R = strtol(RGB_r, 0, 16);
  RGB_G = strtol(RGB_g, 0, 16);
  RGB_B = strtol(RGB_b, 0, 16);

  Serial.println("----------");
  Serial.println(RGB_R);
  Serial.println(RGB_G);
  Serial.println(RGB_B);
}