0

I'd like to know is it possible to add characters between two or more string using LPAD in SQL example sentence 'The Cat Is Sleeping'

LPAD('string', number, '+')

expected results:

++++++The+++++Cat+++++++Is++++++Sleeping

pas :-amount of + above is just an example maybe the result will be different. I hope you can understand my question.

if you are willing give me the exact query thanks

1 Answer 1

1

Your problem is a good candidate for doing a regex replacement with REGEXP_REPLACE:

SELECT REGEXP_REPLACE(input, '^| ', '+++++++') AS output
FROM yourTable;

The output is:

+++++++The+++++++Cat+++++++Is+++++++Sleeping

Demo

Data:

WITH yourTable AS (
    SELECT 'The Cat Is Sleeping' AS input FROM dual
)
Sign up to request clarification or add additional context in comments.

2 Comments

what if i want to add different amount of stars for each word?
...that's a different question, and not what you asked (or what was answered) :-)

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.