Clean String function in SQL Developer

I want to write a function that will look for any variation of the LCF string below and want to replace it with the Last company name in the string, after the last 'LCF' in the string

Example:
Company A LCF COMPANY B L/C/F COMPANY  C

Return: COMPANY C

What to look for:
"LCF", "-LCF", "L/C/F", "L/C/F,", "L.C/F/,", "L/C/F/", "L.C.F", "L.C.F.", "-L/C/F", "L/C/F-", "L-C-F", "LCF/", "L/C/F:", "LCF:", ".L/C/F", "L\C\F", "L\C\F:", ".L\C\F", ".L/C/F", "L C F", "LOST CONTENT FOR", "LOST CONTRACT FOR:"

I would like to pass in
Company A LCF COMPANY B L/C/F COMPANY  C
and get back
COMPANY C

Thanks
jknj72Asked:
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.

jknj72Author Commented:
I don't have a problem finding the variations of LCF and stripping it out, its if there are more then one of them where I am having a problem
0
slightwv (䄆 Netminder) Commented:
Here is what I came up with:
with mydata as (
	select 'MyText lost content for Company A LCF COMPANY B L/C/F COMPANY  C' col1 from dual
)
select
regexp_replace(
	regexp_replace (
		regexp_replace(col1,'[^[:alnum:] ]',null, 1,0,'i'),
		'LOST CONTENT FOR|LOST CONTRACT_FOR','LCF',1,0,'i'
	)
	, '(.*LCF .*LCF )(.*$)','\2'
)
from mydata
/

Open in new window

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
jknj72Author Commented:
I will have to try at work in the am. Glad you responded...Thanks for the help again
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

jknj72Author Commented:
I forgot I downloaded SQL Developer so I was able to test it at home and it worked like a charm
0
jknj72Author Commented:
Great job thanks
0
slightwv (䄆 Netminder) Commented:
Glad to help!

If you find a case where it doesn't, just post a new question and the link to this one and we'll do what we can.
0
jknj72Author Commented:
roger that
0
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.