Replacement in Regular Expression

Hello Experts,

I have a problem in using regular expression in Perl.
I am fetching a value from database and storing it in a variable '$welcome_string'.
The value fetched is unknown, but it contains value something like,

'Welcome %FIRST_NAME% %LAST_NAME% to this portal'.

I want a regular expression which will convert the above string to the following:

'Welcome $params->{'FIRST_NAME'} $params->{'LAST_NAME'} to this portal'.

Kindly provide solution.

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.

This should work.


Open in new window

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
When you say $params->{'FIRST_NAME'} do you mean that literal string, or do you want the value contained in the hash ref?

\w includes _

you don't need to \ the % > { or '  in this context
Aloha_TechnologyAuthor Commented:
Yes, it works.

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

From novice to tech pro — start learning today.