removing a space or spaces within a value

Hello,
I have some part numbers that I would like to add a space within them.
I would like to only add a space within a part number that starts out with a 'LS' or a 'QM'.

So if I have a part number = 'LS18022', I would like to add a space after the 'LS' like 'LS 18022'.
Same thing for the 'QM', 'QM 83212'

So if the part number starts out with a LS or QM add a space within it.

Trying to use regexp_like or regexp_replace or any other solution.

I can use this to remove the space, just need to figure out how to add a space back in.
select trim(regexp_replace('LS 18022','(LS )(\d)' ,'LS\2')) from dual;

This is using Oracle 11g.

Thanks
MachinegunnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MachinegunnerAuthor Commented:
please close question, I figured it out...
This works below..

select trim(regexp_replace('LS18022','(LS)(\d)' ,'LS \2')) from dual;
0
slightwv (䄆 Netminder) Commented:
You can accept your own post or request this be deleted yourself.

That said, regular expression statements are an expensive operation.  You can get what you asked for without them:
with mydata as (
select 'LS18022' col1 from dual
union all
select 'QM18022' from dual
union all
select 'Hello' from dual
)
select case when col1 like 'LS%' or col1 like 'QM%' then substr(col1,1,2) || ' ' || substr(col1,3) else col1 end
from mydata
/

Open in new window

0
sdstuberCommented:
will LS or QM be found anywhere in the middle of the string?  If not, a couple of simple replace calls could do efficiently.


replace(replace(yourcolumn,'LS','LS '),'QM','QM ')
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.