?
Solved

Splitting Strings

Posted on 2003-02-28
4
Medium Priority
?
183 Views
Last Modified: 2010-03-05
Hell0!

I'm trying to split one string into two strings using "|" as the mid-point.. example:

"first_name|First Name:"

i'd like something like->

$id = "first_name"
$lbl = "First Name:"

--------------------------
shouldn't be too hard ;)
--------------------------
0
Comment
Question by:tampabay420
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 22

Accepted Solution

by:
pjedmond earned 150 total points
ID: 8042744
$line="abcdefg|12345678";

($id,$lbl)=split(/\|/,$line);

print "$id - $lbl \n";

is probably what you want?
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 8042755
Basically splits the string at any | symbols and allocates them directly to the variables you require:)
0
 
LVL 1

Author Comment

by:tampabay420
ID: 8042853
dude, you are the man (or woman?), thanx for the help- here are those points i promised!
0
 
LVL 22

Expert Comment

by:pjedmond
ID: 8042876
NP :)
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Six Sigma Control Plans
Suggested Courses

743 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