Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to specify multiple delim in a string

Status
Not open for further replies.

Jeff98

Programmer
Oct 19, 2006
14
US

str="1,2|3 4"
I want to parse this tring into
1
2
3
4
I guess i can use split(str,delim)
but how to specify the delim?

Thanks
Jeff
 
The delimiter in a split is a regex. So you can specify
Code:
my @stuff = split(/[,| ]/, $string);

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
myStr="1,2|3 4"
myArr=Split(Replace(Replace(myStr,"|"," "),","," ")))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Arrgh. Clicked on the VBA forum instead of the perl one, then gave you a perl answer. What a plonker...[blush]

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 



I knew that steve was a gem of a guy! ;-)

"case not your pearls before the swine."

Hmmmmmm? Wonder what that implies?"

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top