Regexp Help
Soumik B, September 05, 2018 - 7:40 am UTC
Thanks Tom for your help and support.
As per requriment the First 4 digit should be there and it also does not need a conversion, along with 0 and 9.
ORIGINAL MOBILE NUMBER: 9845-089160
MASKED MOBILE NUMBER: ****-0*9** (Currently this is the output)
EXPECTED MOBILE NUMBER : 9845-0*9**0 ( This is what business is expecting)
September 05, 2018 - 12:41 pm UTC
Then don't apply the regexp to the first four digits...
version
Racer I., September 05, 2018 - 10:37 am UTC
Hi,
with t as
( select '9845-089160' m_no from dual )
select m_no, substr(m_no, 1, instr(m_no, '-')) || regexp_replace(substr(m_no, instr(m_no, '-') + 1),'1|2|3|4|5|6|7|8','*')
from t
Also : you don't need the m_no-variable in your function. Just use nrr_number_low directly.
Given : function logic should convert one digit at a time and not entire number in one go.
Therefore shouldn't you do this in a char by char loop;)
I think tegexp-wizards could do it without substr/instr. In fact without any extra function at all.
regards,
September 05, 2018 - 12:40 pm UTC
Well rexexp_replace does have a parameter to define the start position for the search. So I doubt the regex needs to be that complicated ;)
Solved::: Regexp_Replace Help- Column Level Data Masking
Soumik B, September 06, 2018 - 9:54 am UTC
Thanks Tom it was awesome, for your help...
September 08, 2018 - 10:24 am UTC
glad we could help