M
M
merlinQ2021-03-30 09:40:53
SQL
merlinQ, 2021-03-30 09:40:53

Replace part of a string between two characters?

Good time!
Can you please tell me how to replace part of a string between two characters?

for example:
DGN-04-13601/21-53 you need to get DGN-04-********/21-53
instead of asterisks there will be a variable text.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
idShura, 2021-03-30
@merlinQ

Here are a couple of examples

--С помощью регулярного выражения
select REGEXP_REPLACE('ДГН-04-13601/21-53', '-\d{1,}/', '-********/') from  dual;

--Если строка всегда одной длины, то можно с помощью substr
select substr('ДГН-04-13601/21-53', 0, 7) || '********' || substr('ДГН-04-13601/21-53', 13) from dual;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question