can you help me to split a string (or preferred if possible, place a blank at every “split” occasion) after every change from alphanumeric to numeric and vice versa ?
So a string like D2c1 22 should look like D 2 c 1 22. Best way from would be to put a blank at every change from alpha-numeric to numeric.
Here’s an approach tested with PostgreSQL and verified to work. It’s a bit tortured, so performance might be … interesting.
We need
array_cat_aggbecause regulararray_aggcan’t aggregate arrays of arrays.Alternately, a form of @davidrac’s approach that’ll work with PostgreSQL and probably perform significantly better (though I haven’t tested) is:
This is executing the replacement in two passes. First it’s inserting a space where series of digits end and series of non-digits begin. Then in another pass it’s inserting spaces where series of non-digits end and series of digits begin.
Update: Here’s an improved formulation: