I have this kind of string 12s2-3a abc def
and I am trying to apply the regexp ^(?=.*\d)
to remove the first part and having as left abc def
.
I have tried with:
select substring ('12s2-3 abc def' from '^(?=.*\d)');
and
select regexp_replace ('12s2-3 abc def', '^(?=.*\d)', '');
but none of those has worked. The only one that looks working is the match verification (~
).
Any idea?
1 Answer 1
Look-ahead are zero width. They don't match anything themselves. So your replacement operations is just replacing the empty string with the empty string, under certain conditions.
Simply removing the look-ahead designation makes it give the answer you want for your one example:
select regexp_replace ('12s2-3 abc def', '^.*\d', '');