Hi: I want to split the string
0.0.0.0.1.10.1.30.1.10.1.30.1
into 4 variables: 0.0.0.0, 1, 10.1.30.1 and 10.1.30.1
any suggestions?
TIA
ravi
__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
--
To unsubscribe,
On Dec 10, 2003, at 4:49 PM, Ravi Malghan wrote:
Hi: I want to split the string
0.0.0.0.1.10.1.30.1.10.1.30.1
into 4 variables: 0.0.0.0, 1, 10.1.30.1 and 10.1.30.1
any suggestions?
yes, get better data.
a part of the problem you have is the that you
could do this with a regEx
my $input
Ravi Malghan wrote:
Hi: I want to split the string
0.0.0.0.1.10.1.30.1.10.1.30.1
into 4 variables: 0.0.0.0, 1, 10.1.30.1 and 10.1.30.1
any suggestions?
TIA
ravi
Here is one approach:
#!perl -w
use strict
$_ = '0.0.0.0.1.10.1.30.1.10.1.30.1';
my @MyWorka = ();
@MyWorka = split(/\./,
For those of you that are interested, I benchmarked a few of the
suggestions. Drieux is by a significant margin the winner speed-wise.
What I did was split the scalar into an array and then define the four
variables by join()ing the result using an array slice instead of making
a new array.
Janek Schleicher wrote at Sat, 07 Sep 2002 10:06:34 +0200:
...
print join \n, grep defined, ($string =~ /(.*?)|(\w+)/g);
...
The regexp matches either (.*?) in $1 or (\w+) in $1.
^^
Of course, I meant $2.
But the regexp always makes a
Wiggins D'Anconia wrote at Sat, 07 Sep 2002 05:34:55 +0200:
Octavian Rasnita wrote:
Hi and thank you. It works!
Could you explain me please in a few words what is this line doing exactly?
I want to learn.
print join \n, grep defined, ($string =~ /(.*?)|(\w+)/g);
[snipped very good
Octavian Rasnita wrote at Thu, 05 Sep 2002 20:09:58 +0200:
I want to split a string but it is a little too complicated for me.
If it is too complicated, don't give me an answer but just a little hint to
the right direction.
I have a string like the following example (used to search in a
On Thu, 5 Sep 2002 21:09:58 +0300, [EMAIL PROTECTED] (Octavian Rasnita)
wrote:
I want to split a string but it is a little too complicated for me.
If it is too complicated, don't give me an answer but just a little hint to
the right direction.
I have a string like the following example (used to
PROTECTED]
Sent: Friday, September 06, 2002 2:54 PM
Subject: Re: Splitting a string
Octavian Rasnita wrote at Thu, 05 Sep 2002 20:09:58 +0200:
I want to split a string but it is a little too complicated for me.
If it is too complicated, don't give me an answer but just a little hint
to
the right
:54 PM
Subject: Re: Splitting a string
Octavian Rasnita wrote at Thu, 05 Sep 2002 20:09:58 +0200:
I want to split a string but it is a little too complicated for me.
If it is too complicated, don't give me an answer but just a little hint
to
the right direction.
I have a string like
Hi all,
I want to split a string but it is a little too complicated for me.
If it is too complicated, don't give me an answer but just a little hint to
the right direction.
I have a string like the following example (used to search in a search
engine):
perl editor free blind accessible
I
I am sure one of the gurus probably has a cool regex to do this, but I
haven't gotten to that book yet ;-)
One solution and by no means the fastest or shortest, would be to split
on space, then step through your returned list checking the beginning of
each element, if that element
I know many have probably answered this but Im just going down my email
list. Here is the answer:
@asplit = split(//,$a);
That should be it.
- Jim
At 22:41 03.20.2002 -0800, Raja Gopal wrote:
Hello Perl Experts,
I want to split the string $a =abcdef;
as @asplit = (a,b,c,d,e,f).
Is
$a ='abcdef';
@arr = split(//,$a);
print @arr;
--
From: Raja Gopal[SMTP:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 12:11 PM
To: [EMAIL PROTECTED]
Subject: splitting the string.
Hello Perl Experts,
I want to split the string $a =abcdef
just do
$a =abcdef;
@asplit = split //,$a;
Amit
-Original Message-
From: Raja Gopal [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 21, 2002 8:41 AM
To: [EMAIL PROTECTED]
Subject: splitting the string.
Hello Perl Experts,
I want to split the string $a =abcdef;
as @asplit
Jenda Krynicky wrote:
John W. Krahn [EMAIL PROTECTED] suggested:
my @s = split //, $s;
my @s = unpack 'a' x length $s, $s;
my @s = $s =~ /./gs;
push @s, substr $s, $_, 1 for 0 .. length $s - 1;
push @s, chr vec $s, $_, 8 for 0 .. length $s - 1;
Also
Jenda Krynicky wrote:
John W. Krahn [EMAIL PROTECTED] suggested:
my @s = split //, $s;
my @s = unpack 'a' x length $s, $s;
my @s = $s =~ /./gs;
push @s, substr $s, $_, 1 for 0 .. length $s - 1;
push @s, chr vec $s, $_, 8 for 0 .. length $s - 1;
Also
unshift @s,
If I have a string
$s='ABC';
how can I split it into one-char-long-element-array like
@s=('A','B','C');
and, generally how can I access individual characters of a string variable?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
I.J. wrote:
If I have a string
$s='ABC';
how can I split it into one-char-long-element-array like
@s=('A','B','C');
and, generally how can I access individual characters of a string variable?
my @s = split //, $s;
my @s = unpack 'a' x length $s, $s;
my @s = $s =~ /./gs;
push @s,
On Sun, Dec 16, 2001 at 06:19:40AM -0800, John W. Krahn wrote:
I.J. wrote:
If I have a string
$s='ABC';
how can I split it into one-char-long-element-array like
@s=('A','B','C');
and, generally how can I access individual characters of a string variable?
substr()
But might I
You're actually very close. I would just change a couple of things.
First of all, you don't need @data as well as @rows. $element is aliased to
each element in the array as it loops, so you can re-assign right back into
the same array when you split. This will cause the loop to independent of
21 matches
Mail list logo