> -Original Message-
> From: Grant [mailto:emailgr...@gmail.com]
> Sent: Tuesday, April 21, 2009 12:55
> To: Perl Beginners List
> Subject: Re: String manipulation question
>
> >> >> >> Thanks guys. With some help I've come up with this:
> -Original Message-
> From: Grant [mailto:emailgr...@gmail.com]
> Sent: Tuesday, April 21, 2009 12:43
> To: Perl Beginners List
> Subject: Re: String manipulation question
>
> >> >> Thanks guys. With some help I've come up with this:
> >>
> -Original Message-
> From: Grant [mailto:emailgr...@gmail.com]
> Sent: Tuesday, April 21, 2009 12:16
> To: Perl Beginners List
> Subject: Re: String manipulation question
>
> >> Thanks guys. With some help I've come up with this:
> >>
> >
> -Original Message-
> From: Grant [mailto:emailgr...@gmail.com]
> Sent: Tuesday, April 21, 2009 11:47
> To: Perl Beginners List
> Subject: Re: String manipulation question
>
> >> I'd like to take a string and manipulate it in a few ways.
> >>
&g
> -Original Message-
> From: Grant [mailto:emailgr...@gmail.com]
> Sent: Tuesday, April 21, 2009 09:58
> To: Perl Beginners List
> Subject: String manipulation question
>
> I'd like to take a string and manipulate it in a few ways.
>
> If the string is 34 characters or less, I'd like to
>>> if you have in $string = q[1234 12345 12 5346 12367 123 123678123];
>>> Then $var1 will be '1234 12345 12 5346 12367 123 12367', but I thought you
>>> wanted '1234 12345 12 5346 12367 123'?
>>> Which one is the right one for what you are doing?
>>
>> You're right, I would want:
>>
>> 1234 12345
>> >> >> >> Thanks guys. With some help I've come up with this:
>> >> >> >>
>> >> >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz';
>> >> >> >> if(length($string) = 34) {$var1 = $string.":";}
>> >> >> >
>> >> >> > '=' is assignment, '==' is test for numerical equality.
>> >> >> Change the abov
On 4/21/09 Tue Apr 21, 2009 11:54 AM, "Grant"
scribbled:
>> if you have in $string = q[1234 12345 12 5346 12367 123 123678123];
>> Then $var1 will be '1234 12345 12 5346 12367 123 12367', but I thought you
>> wanted '1234 12345 12 5346 12367 123'?
>> Which one is the right one for what you are
On 4/21/09 Tue Apr 21, 2009 11:42 AM, "Grant"
scribbled:
> I'm trying to pull 35 or fewer characters to the nearest space
> basically. This is what I have now:
>
> if(length($string) <= 34) {$var1 = $string.":";}
> if(length($string) > 34) {
> ($var1, $var2) = ($string =~ /(.{35})(.{26})/);
>> >> >> Thanks guys. With some help I've come up with this:
>> >> >>
>> >> >> $string = 'abc def ghi jkl mno pqr stu vwx yz';
>> >> >> if(length($string) = 34) {$var1 = $string.":";}
>> >> >
>> >> > '=' is assignment, '==' is test for numerical equality.
>> >> Change the above
>> >> > line to:
>>
>> >> Thanks guys. With some help I've come up with this:
>> >>
>> >> $string = 'abc def ghi jkl mno pqr stu vwx yz';
>> >> if(length($string) = 34) {$var1 = $string.":";}
>> >
>> > '=' is assignment, '==' is test for numerical equality.
>> Change the above
>> > line to:
>> > if( length($string
$string =~ s/\s//g;
>>>
>>> The above line deletes all of the spaces in $string. Is that what you want
>>> to do?
>>
>> All fixed up except for this. How can I remove only the spaces at the
>> end of $var1 and $var2 if they exist?
>
> Anchor your substitution regular expression to the end o
On 4/21/09 Tue Apr 21, 2009 11:16 AM, "Grant"
scribbled:
>>> $string =~ s/\s//g;
>>
>> The above line deletes all of the spaces in $string. Is that what you want
>> to do?
>
> All fixed up except for this. How can I remove only the spaces at the
> end of $var1 and $var2 if they exist?
Anc
>> Thanks guys. With some help I've come up with this:
>>
>> $string = 'abc def ghi jkl mno pqr stu vwx yz';
>> if(length($string) = 34) {$var1 = $string.":";}
>
> '=' is assignment, '==' is test for numerical equality. Change the above
> line to:
> if( length($string) == 34 ) { $var1 = $string
On 4/21/09 Tue Apr 21, 2009 10:46 AM, "Grant"
scribbled:
> Thanks guys. With some help I've come up with this:
>
> $string = 'abc def ghi jkl mno pqr stu vwx yz';
> if(length($string) = 34) {$var1 = $string.":";}
'=' is assignment, '==' is test for numerical equality. Change the above
line t
>> I'd like to take a string and manipulate it in a few ways.
>>
>> If the string is 34 characters or less, I'd like to append a colon
>> character and save it to $var1.
>
> The length function will tell you how many characters are in a string.
>
>>
>> If the string is longer than 34 characters, I'
On 4/21/09 Tue Apr 21, 2009 8:58 AM, "Grant"
scribbled:
> I'd like to take a string and manipulate it in a few ways.
>
> If the string is 34 characters or less, I'd like to append a colon
> character and save it to $var1.
The length function will tell you how many characters are in a string.
Andrew Curry schreef:
> /\s*(\S+)\s*=\s*(\S+)[,\s*\/*]?/
Anchored alternative:
/^\s*(\w+)\s*=\s*(\w+)/
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Thanks Everyone for your suggestions. It really helped.
I shall freshen up from the documents suggested to me.
But anyways, i would like to say, that unless any one works on any language,
mastering it is difficult. When i go through the tutorials or documents, i
seem to know. But practically, onl
But in this case it was also not needed as I replied without actually
reading the requirements.
-Original Message-
From: Paul Lalli [mailto:[EMAIL PROTECTED]
Sent: 31 July 2007 14:21
To: beginners@perl.org
Subject: Re: String Manipulation
On Jul 31, 8:40 am, [EMAIL PROTECTED
On Jul 31, 8:40 am, [EMAIL PROTECTED] (Dharshana Eswaran) wrote:
> And your suggestion worked. Thank you. But in the string which u had
> suggested, [,\s*\/*]?, here \s* => tells spaces are optional,
No it doesn't. The "dirty dozen" characters lose their special
meaning inside of a character clas
Oops!!! Sorry, It is ([A-Z0-9_]+). It was a typo in my mail.
And your suggestion worked. Thank you. But in the string which u had
suggested, [,\s*\/*]?, here \s* => tells spaces are optional, /\* sells the
beginning of the comment, I am unable to understand what these in a square
bracket along wit
Dharshana Eswaran wrote:
I have a string which reads
$str5 = "DL_FEM_ADJ1 = DL_FEM_LINE_FIRST, /* Keep the adjacent ones
consecutive */";
Here i need to consider the variable and its value, ignoring the comment.
I have a pattern which reads
if($str5 =~ /\s*([A-Z_]+)\s=\s(\w+),*/) {
pr
Try
if($str5 =~ /\s*(\S+)\s*=\s*(\S+)[,\s*\/*]?/)
I cant see how your
([A-Z_]+)
Will match your DL_FEM_ADJ1 as this has a number on it?
-Original Message-
From: Dharshana Eswaran [mailto:[EMAIL PROTECTED]
Sent: 31 July 2007 13:17
To: Perl Beginners
Subject: String Manipulation
Hi
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
On 6/28/07, Tom Phoenix <[EMAIL PROTECTED]> wrote:
>
> On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
>
> > I am unable to get a generalised way in which it can extract them as few
> > structures have comments, few does not hav co
On 6/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
Thank you. But i am unable to understand the working of the code which you
have written. Can you please explain it?
Thanks and Regards,
Dharshana
What, specifically, do you not understand?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
Fo
Thank you. But i am unable to understand the working of the code which you
have written. Can you please explain it?
Thanks and Regards,
Dharshana
On 6/28/07, Chas Owens <[EMAIL PROTECTED]> wrote:
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> On 6/28/07, Tom Phoenix <[EMAIL PROTECT
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
On 6/28/07, Tom Phoenix <[EMAIL PROTECTED]> wrote:
>
> On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
>
> > I am unable to get a generalised way in which it can extract them as few
> > structures have comments, few does not hav co
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
I am restricted from using modules and i am unable to come up
with a regex or regexes to do this job.
So, the Pointy-Haired Boss won't let you use any module that didn't
come with Perl?
Even if you can't use Parse::RecDescent in your fi
On 6/28/07, Tom Phoenix <[EMAIL PROTECTED]> wrote:
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> I am unable to get a generalised way in which it can extract them as few
> structures have comments, few does not hav comments etc.
Does the data have some defined grammar, or a defina
On 6/27/07, Tom Phoenix <[EMAIL PROTECTED]> wrote:
snip
Does the data have some defined grammar, or a definable one at least?
If you are up to using Parse::RecDescent, it will probably do the job.
snip
Many people are afraid to use Parse::RecDescent because of the
learning curve involved. I fi
On 6/27/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
I am unable to get a generalised way in which it can extract them as few
structures have comments, few does not hav comments etc.
Does the data have some defined grammar, or a definable one at least?
If you are up to using Parse::RecDesc
Jerry Preston wrote:
> Hi!
>
> I am trying to figure out a simple, Perl way to break down any sting
> similar to the following:
>
> $s0 =
>
"01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
> 26,27,28,29";
>
> Or in any numeric order. The string cannot be longer than
On Mon, 19 Jan 2004, Jerry Preston wrote:
> I am trying to figure out a simple, Perl way to break down any sting similar
> to the following:
>
> $s0 =
> "01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,
> 26,27,28,29";
>
> Or in any numeric order. The string cannot b
03 5:36 PM
To: [EMAIL PROTECTED]
Subject: Re: String manipulation problem
[EMAIL PROTECTED] wrote:
> Hi,
>
> While reading each line in a file, If I find a certain number, I need
> to increment a digit within that number. For example, when reading
> through my file, I expect t
[EMAIL PROTECTED] wrote:
> Hi,
>
> While reading each line in a file, If I find a certain number, I need to
> increment a digit within that number. For example, when reading through my
> file, I expect to find the following line.
>
> #define DS_FILEVERSION7,0,0,0462
>
> What I want to d
[EMAIL PROTECTED] wrote:
> Hi,
>
> While reading each line in a file, If I find a certain number, I need
> to increment a digit within that number. For example, when reading
> through my file, I expect to find the following line.
>
> #define DS_FILEVERSION 7,0,0,0462
>
> What I want to do is have t
> #define DS_FILEVERSION7,0,0,0462
>
> What I want to do is have the ability to increment the first
> two zero's
> after the 7 on demand. I may accasionaly want to increment
> the first zero,
> making the number 7,1,0,0462, or a I may want to just
> increment the second
> zero, making t
Maybe something like this will help simplify it...
s/(\d),(\d),(\d+),(\d{4})/fixNums($1,$2,$3,$4)/e;
sub fixNums
{
my @nums = @_;
# bump the second
$nums[1]++;
# or bump the third
$nums[2]++;
# or bump on some condition
$nums[1]++ if ($nums[0] == 7);
return join(',', @nums); #
From: "John W. Krahn" <[EMAIL PROTECTED]>
> Pavle Lukic wrote:
> > Problem
> > Given a string and a pattern, construct new string
> > by removing part of the string equal to pattern.
> > Remove only first occurrence of the pattern.
> >
> > Problem solutions
> >
> > Solution #1 ($x = $a) =~ s/\Q$b
nd perhaps
why the second takes appx half the time to do?
I'd love to understand this better.
Thanks
Dan
-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 08, 2003 9:37 AM
To: [EMAIL PROTECTED]
Subject: Re: String manipulation benchmark
Pavle Lukic wrote:
>
> Hi
Hello,
> I did a little benchmarking in regard to the
> string manipulation issue raised on this forum.
>
> Here are relevant parameters and benchmark results.
>
> Problem
> Given a string and a pattern, construct new string
> by removing part of the string equal to p
Thanks John,
I may have to go along with Drieux and "Let it be known" YOU are The GOD
of regEx!
-Original Message-
From: John W. Krahn [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 6:48 PM
To: [EMAIL PROTECTED]
Subject: Re: string manipulation
Jaimee Spe
On Wednesday, May 1, 2002, at 06:47 , John W. Krahn wrote:
> Jaimee Spencer wrote:
[..]
>>
>>I know I am missing something basic here also, but tell me in the
>> example
>> (my $projectId) = $projectDocDir =~ m!.*/(\w+)/!;
>> why isn't the /1_0001.doc being printed as well?
>
> Because the
Jaimee Spencer wrote:
>
> From: John W. Krahn [mailto:[EMAIL PROTECTED]]
> >
> > Either of these should work:
> >
> > (my $projectId) = $projectDocDir =~ m!.*/(\w+)/!;
> >
> > # or
> >
> > my $projectId = (split /\//, $projectDocDir)[-2];
>
>I know I am missing something basic here also,
EMAIL PROTECTED]]
Sent: Wednesday, May 01, 2002 4:18 PM
To: [EMAIL PROTECTED]
Subject: Re: string manipulation
Garrett Esperum wrote:
>
> Hi all,
Hello,
> I am using Solaris, Perl 5.
> I am having some problems manipulating strings.
> The string I am manipulating is:
>
>
On Wednesday, May 1, 2002, at 04:18 , John W. Krahn wrote:
> Garrett Esperum wrote:
[..]
>>
>> /export/home/user/www/doc-root/dir/projects/19463/1_0001.doc
>>
>> $projectId = substr($projectDocDir, length($dir), index($projectDocDir,
>> "/",
>> length($dir)));
you might want to perldoc File::B
EMAIL PROTECTED]
Subject: Re: string manipulation
On Wed, 2002-05-01 at 18:52, garrett esperum wrote:
> Hi all,
>
> I am using Solaris, Perl 5.
>
> I am having some problems manipulating strings.
>
> The string I am manipulating is:
>
> /export/home/user/www/doc-ro
On Wed, 2002-05-01 at 18:52, garrett esperum wrote:
> Hi all,
>
> I am using Solaris, Perl 5.
>
> I am having some problems manipulating strings.
>
> The string I am manipulating is:
>
> /export/home/user/www/doc-root/dir/projects/19463/1_0001.doc
>
> I am trying to take out the "19463" part
Garrett Esperum wrote:
>
> Hi all,
Hello,
> I am using Solaris, Perl 5.
> I am having some problems manipulating strings.
> The string I am manipulating is:
>
> /export/home/user/www/doc-root/dir/projects/19463/1_0001.doc
>
> I am trying to take out the "19463" part from the string and insert
In article <[EMAIL PROTECTED]> wrote "Brett
W. McCoy"
<[EMAIL PROTECTED]>:
> On Thu, 14 Feb 2002, Brian Johnson wrote:
>
>> I need a string in the form
>> Wed, 18 Jul 2001 14:20
>>
>> Of course my line doesn't quite cut it.
>> my $emaildate = join " ", $record->{day}, $record->{month},
>>
On Thu, 14 Feb 2002, Brian Johnson wrote:
> I need a string in the form
> Wed, 18 Jul 2001 14:20
>
> Of course my line doesn't quite cut it.
> my $emaildate = join " ", $record->{day}, $record->{month},
> $record->{year}, $record->{hour}, $record->{minute};
Just interpolate the variables d
30:56 +0530 (IST)
From: Deen Hameed <[EMAIL PROTECTED]>
To: Hubert Ian M. Tabug <[EMAIL PROTECTED]>
Cc: Perl <[EMAIL PROTECTED]>
Subject: Re: string manipulation
something like this should work...
(@somearray) = split(/\(.*\)/, $a);
On Sat, 26 Jan 2002, Hubert Ia
>
| Given the string:
|
| $a = "xxx xxx xxx xxx xxx xxx xxx (Jan 12 1990 ..)"
|
| I want to selectively extract that part of the string
| having the (Jan 12 1990 ...) and store it in an array.
| Can someone guide me?
:
: something like this should work...
:
: (@somearray) = split(/\(.*
something like this should work...
(@somearray) = split(/\(.*\)/, $a);
On Sat, 26 Jan 2002, Hubert Ian M. Tabug wrote:
> Hi,
>
> Given the string $a = "xxx xxx xxx xxx xxx xxx xxx (Jan 12
> 1990 ..)", I wan't to selectively extract that part of the string
> having the
> Whats a bash prompt??
A shell prompt (bash is a 'shell'). Otherwise known as
a command line. A place where you type in commands.
I guess you ain't using a flavor of unix.
If you're using Windows, you can do roughly the same
thing as I suggested, only you'll need to fiddle with the
characters
Whats a bash prompt??
Ok OK let me see if i have it
the name of the string is EightyCharsLong
$EightyCharsLong
and the substr command is like the midstring command
substr()
I'm going to guess the first charecter is 0 so that 19 becomes the 20th position???
and of course the 10 is for the legt
> In BASIC there are commands for
> leftstring, midstring, and rightstring.
> I am looking for the perl equiv for these.
> Lets say i have a string 80 charecters long and i
> want to insert at string position 20 for 10 charecters.
substr($EightyCharsLong, 19, 10) = 'morestring';
Yes, you ca
58 matches
Mail list logo