Trying to parse a sting using SQL, and have not found any solutions online (apologies, maybe I'm looking for the wrong thing).
I have a string field with a series of numbers I need to pull out and sum. Delimiter is "\r\n".
Example: '\r\n - 1234 somenumbersandtext123 \r\n -5678 sometextmorenumbers123'
So in this example, I want to sum 1234 and 5678.
The stings are all different lengths, and I need to eventually sum the numbers within the string. The string details documents tied to a project, and the numbers represent the size of the file (trying to determine the total file size per project).
Thanks in advance for any guidance.
regexp_split_to_tablewith t(x) as (values('- 232554 /sometext.pdf\r\n- 27491.70 /morewords\r\n- 138283 /filename.pdf\r\n')) select n[1]::numeric from t, regexp_matches(x,'\d+\.?\d*','g') as n;'\\r\\n[^\d]*(\d+\.?\d*)'regexp_matches(col,'(?:^|\n)\s*-\s*(\d*\.?\d+)','g'). If\nin the input is a 2 char combination, replace\nwith\\n