I have a field that contains mixed data with an id number that I want extract to another column. The column I wish to extract from has some records that match the format ‘lastname, firstname-ID’. I only want to strip the ‘ID’ part, and from those columns who have a ‘-‘ and numbers following it.
So what I was trying to do was…
update data.xml_customerqueryrs
set new_id = regexp_replace(name, '[a-z]A-Z]', '')
where name like '%-%';
I know there is something minor that I need to fix, but I am not sure as the postgresql documentation for pattern matching doesn’t really do a good job covering searching for only numerics.
Or you can also do:
Ref: Strings