?
Solved

Split

Posted on 2005-03-04
4
Medium Priority
?
366 Views
Last Modified: 2010-03-05
$var = "Firstname:Lastname";

I want to split $var on ":". I know how to do that. But what I want to know is that there any way to get the Lastname directly.

I don't mean something like this ($first,$last) = split(/:/,$var);

I mean to say something like split(/:/,$var)[1] .....is this possible to get last name directly.....in this manner.

Ash
0
Comment
Question by:ashish_wale
[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
4 Comments
 
LVL 13

Accepted Solution

by:
gripe earned 200 total points
ID: 13462635
$lastname = (split(/:/, $var))[1];
0
 

Author Comment

by:ashish_wale
ID: 13462738
Thanks gripe....I was missing the outer brackets....thanks dude
0
 
LVL 16

Expert Comment

by:manav_mathur
ID: 13467197
Did you understand why the outer bracket is necessary??

Manav

0
 
LVL 84

Expert Comment

by:ozo
ID: 13467259
(and the inner bracket is unnecesary)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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

800 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