I am working with a Transformation logic in Databricks. Basically there is field called rip_fw which has values like "LC.JO.P051S1-1250" , "LF.030707 23:54-496" like this , as per business requirements a new field called base_fw has to be created where it should only have values like "LC.JO.P051S1" , "LF.030707". So from rip_fw it is only taking considering the dots and any other character after that should be violated. So i wrote a code
CASE
WHEN INSTR(rip_fw, '.') > 0 AND REGEXP_COUNT(rip_fw,'\\.') = 2 THEN
-- Strict match of three alphanumeric segments separated by dots
REGEXP_EXTRACT(rip_fw, '^([A-Za-z0-9]+\\.[A-Za-z0-9]+\\.[A-Za-z0-9]+)', 1)
WHEN INSTR(rip_fw, '.') > 0 AND REGEXP_COUNT(rip_fw,'\\.') = 1 THEN
REGEXP_EXTRACT(rip_fw, '^([A-Za-z0-9]+\\.[A-Za-z0-9]+)', 1)
ELSE rip_fw
END AS base_fw
But it seems not working as expected. can someone help me to identify what is wrong in the code?
^[^ -]+regex