0

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?

asked Jul 13, 2017 at 8:04

1 Answer 1

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', '');
answered Jul 18, 2017 at 23:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.