Solved

substitute string

Posted on 2002-07-10
1
138 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
ID: 7145379
$name =~s/(.)/^$1#/gs;
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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 Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

813 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

15 Experts available now in Live!

Get 1:1 Help Now