postgresql - How to "not include" some piece in regex pattern -


given string 12,.34.56

i need split string point (.), these points, previous character not comma (,)

that is, string above, must retrieve result

12,.34 56 

i trying this:

select regexp_split_to_table('12,.34.56', e'[^,]\\\.')

this returns:

    12,.3     56 

as see, symbol 4 removed, reason understood: [^,] means "some symbol" except comma, , in case, "some symbol" turned 4

question: how prevent this? how not include piece: [^,] in pattern?

since not supported postgres regular expressions, workaround replace ,. (unique) combination of characters , later convert back:

select replace(unnest(string_to_array(                replace('12,.34.56.78,.34', ',.','~^~'), '.')), '~^~', ',.') 

i using unnest(sting_to_array()) instead of regexp_split_to_table() because has shown scale better.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -