0

I have a problem.. I need to extract from this field:

exchange<=><br>type<=>full<br>cont<=>part<br>req<=>no<br>money<=>money<br>money<=>3100,4000,0,month<br>boss<=>0

five informations:

  1. full
  2. part
  3. 3100 4.4000 5.month

I have tried to use regexp_substr(): regexp_substr(column,'type<=>[^<br>]*') but I dont have any knowledge about regex and I cant do it in a properly way.. can you help me with that?

monika_w091
  • 41
  • 1
  • 5

1 Answers1

0

I never worked with redshift but with regex I can help you:

"(type|cont|money)<=>([^<,]+)(,([^<,]+),[^<,]+,([^<,]+))?"

The capture number 4 in the string you put as an example it will capture all you need, it even exclude the 0 :

Group 1: money
Group 2: 3100
Group 3: ,4000,0,month Group 4: 4000
Group 5: month

In case you have problems, tell me. If you want to master your regex skills I can teach you, it will be useful.

nhahtdh
  • 55,989
  • 15
  • 126
  • 162
YOGO
  • 531
  • 4
  • 5
  • wait, I will fix it – YOGO Sep 10 '18 at 17:43
  • Look at this link, https://stackoverflow.com/questions/7758859/how-to-extract-group-from-regular-expression-in-oracle You have to specify the capturing group you want, in that case is the second , I gess, because I can not try this regex in redshift – YOGO Sep 10 '18 at 17:56
  • In the last case you need to specify that you want the group 2 , 4 and 5 – YOGO Sep 10 '18 at 17:59
  • Here is explained better : https://www.w3resource.com/oracle/character-functions/oracle-regexp_substr-function.php – YOGO Sep 10 '18 at 18:04