2

I'm trying to write a function that can decode a message by switching pairs of characters around.

Say I have the message hello! which, when encoded, turns into ehll!o. Is there an existing function in Oracle that lets me replace characters at specified positions with other characters of my choosing?

3 Answers 3

9

You should use regex that looks like a tits:

regexp_replace(string, '(.)(.)', '\2\1')

fiddle

Sign up to request clarification or add additional context in comments.

Comments

1

You'd be looking for SubStr() I believe. Possibly Translate() or Replace().

Comments

0

If you want to simply mask few characters from a particular position, you could like below

SUBSTR(field_name,1,4) || 'XXXX' || SUBSTR(field_name,LENGTH(field_name)-4,LENGTH(field_name))
as field_name

If the field values is 0007125009300 Output will be 0007XXXX09300

Comments

Your Answer

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.