Solved

substitute string

Posted on 2002-07-10
1
136 Views
Last Modified: 2010-03-05
Can anyone give me ahand with the following....

I would like to put ^ before every character and # after every character in a string of any length.

I have tried
$name = 123;
$name =~s/\B/#/g;
return $name;

and get 1#2#3

but have no idea how to get ^1#^2#^3#

Regards,
geoff
0
Comment
Question by:wapware
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
Comment Utility
$name =~s/(.)/^$1#/gs;
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now