Re: substring first 100 words from a string in perl

2011-08-01 Thread Rob Dixon
On 01/08/2011 19:14, Dr.Ruud wrote: my ($rtioverview) = $string =~ /(.{0,100})\b/; That would have to be my ($rtioverview) = $string =~ /(.{0,99})\S\b/; to avoid terminating at the start of a non-space sequence. Rob -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional

Re: substring first 100 words from a string in perl

2011-08-01 Thread Dr.Ruud
On 2011-07-28 15:23, Khabza Mkhize wrote: I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg "breathtaking" on my string is only bre. $string = "This is an awe-inspiring tour to the

RE: substring first 100 words from a string in perl

2011-07-29 Thread Bob McConnell
My first impression was that he wanted the first hundred characters rounded off to the previous or next full word. It sounded like he wanted smart line breads at the word boundaries. Bob McConnell From: timothy adigun > I get the point you are making here, if you check the subroutine "sub > che

Re: substring first 100 words from a string in perl

2011-07-28 Thread timothy adigun
Hi Rob, I get the point you are making here, if you check the subroutine "sub checkStr{}" you see dat it confirm what you are pointing out. However, I think the point there is the number of words the programmers wants! [Khabza, correct me if am wrong]. Since, split function as indicated will remov

Re: substring first 100 words from a string in perl

2011-07-28 Thread Rob Dixon
On 28/07/2011 14:23, Khabza Mkhize wrote: I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg "breathtaking" on my string is only bre. $string = "This is an awe-inspiring tour to the

Re: substring first 100 words from a string in perl

2011-07-28 Thread timothy adigun
Hello Khabza, " I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg "breathtaking" on my string is only bre." -- If you count your $string alphabeth by alphabeth from 0 to 100 including eve

Re: substring first 100 words from a string in perl

2011-07-28 Thread timothy adigun
Hi Rob Coops, " I want to substring words, I might be using wrong terminology. But I tried the following example the only problem I have it cut word any where it likes. eg "breathtaking" on my string is only bre." -- If you count your $string alphabeth by alphabeth from 0 to 100 including ev

Re: substring first 100 words from a string in perl

2011-07-28 Thread Rob Coops
On Thu, Jul 28, 2011 at 3:23 PM, Khabza Mkhize wrote: > I want to substring words, I might be using wrong terminology. But I tried > the following example the only problem I have it cut word any where it > likes. eg "breathtaking" on my string is only bre. > > > $string = "This is an awe-in

Re: substring of a string delimited by "/"

2007-05-11 Thread Rob Dixon
Nishi wrote: I have a string of the format - abc/def/ghi or abc\def\ghi I want to strip of abc and return just def/ghi or def\ghi How do I do that? use strict; use warnings; foreach (qw( abc/def/ghi abc\def\ghi )) { (my $trim = $_) =~ s|.*?[/\\]||; print "$_ -> $trim\n"; } **OUTPUT**

Re: substring

2005-08-17 Thread marcos rebelo
On 8/17/05, Paul Johnson <[EMAIL PROTECTED]> wrote: > On Wed, Aug 17, 2005 at 06:26:16PM +0100, marcos rebelo wrote: > > > If I'm not wrong, Changing this lines: > > > > my @col = grep(!/\t/, split(/(\t)/, $line)); > > push(@col, "") if $line =~ /\t$/; > > > > > > b

Re: substring

2005-08-17 Thread Paul Johnson
On Wed, Aug 17, 2005 at 06:26:16PM +0100, marcos rebelo wrote: > If I'm not wrong, Changing this lines: > > my @col = grep(!/\t/, split(/(\t)/, $line)); > push(@col, "") if $line =~ /\t$/; > > > by > > > $line .= "\t"; > my @col;

Re: substring

2005-08-17 Thread Jeff 'japhy' Pinyan
On Aug 17, marcos rebelo said: my @col = grep(!/\t/, split(/(\t)/, $line)); push(@col, "") if $line =~ /\t$/; Wow. That could have just been my @col = split /\t/, $line; push @col, "" if $line =~ /\t$/; which should REALLY have been written as my @col = split /\t/, $line, -1; The

Re: substring problems

2003-03-19 Thread tao wang
thanks a lot. - tao --- "John W. Krahn" <[EMAIL PROTECTED]> wrote: > Tao Wang wrote: > > > > thanks a lot. But there is one problem - this is > my > > fault. The KEY1, KEY2 don't exactly look like > this. > > There are six KEYS. Three are related to KEYS, but > the > > rest of them are A_BEG A

Re: substring problems

2003-03-19 Thread Rob Dixon
Tao Wang wrote: > thanks a lot. But there is one problem - this is my > fault. The KEY1, KEY2 don't exactly look like this. > There are six KEYS. Three are related to KEYS, but the > rest of them are A_BEG A_END, B_OPTIONS, and I need to > extract information between them. I used one variable > $o

Re: substring problems

2003-03-19 Thread tao wang
no special order. thanks. - tao --- Wiggins d'Anconia <[EMAIL PROTECTED]> wrote: > > > tao wang wrote: > > thanks a lot. But there is one problem - this is > my > > fault. The KEY1, KEY2 don't exactly look like > this. > > There are six KEYS. Three are related to KEYS, but > the > > rest of

Re: substring problems

2003-03-19 Thread Wiggins d'Anconia
tao wang wrote: thanks a lot. But there is one problem - this is my fault. The KEY1, KEY2 don't exactly look like this. There are six KEYS. Three are related to KEYS, but the rest of them are A_BEG A_END, B_OPTIONS, and I need to extract information between them. I used one variable $op=KEY1|

Re: substring problems

2003-03-19 Thread John W. Krahn
Tao Wang wrote: > > thanks a lot. But there is one problem - this is my > fault. The KEY1, KEY2 don't exactly look like this. > There are six KEYS. Three are related to KEYS, but the > rest of them are A_BEG A_END, B_OPTIONS, and I need to > extract information between them. I used one variable >

Re: substring problems

2003-03-19 Thread tao wang
thanks a lot. But there is one problem - this is my fault. The KEY1, KEY2 don't exactly look like this. There are six KEYS. Three are related to KEYS, but the rest of them are A_BEG A_END, B_OPTIONS, and I need to extract information between them. I used one variable $op=KEY1|KEY2|KEY3|A_BEG|A_

Re: substring problems

2003-03-18 Thread John W. Krahn
Tao Wang wrote: > > Hi Everyone, Hello, > I'm having a problem with extracting certain strings > within a line. I tried several ways, but not very > inefficient. Can somebody help me with it? thanks a > lot. > > The line might be one of the following: > KEY1 3 4 T KEY2 > > KEY1 3

Re: substring problems

2003-03-18 Thread Wiggins d'Anconia
tao wang wrote: Hi Everyone, I'm having a problem with extracting certain strings within a line. I tried several ways, but not very inefficient. Can somebody help me with it? thanks a lot. The line might be one of the following: KEY1 3 4 T KEY2 KEY1 3 4 T KEY2 456 67 KEY3 K

Re: substring problems

2003-03-18 Thread Rob Dixon
Tao Wang wrote: > Hi Everyone, > > I'm having a problem with extracting certain strings > within a line. I tried several ways, but not very > inefficient. Can somebody help me with it? thanks a > lot. > > The line might be one of the following: > KEY1 3 4 T KEY2 > > KEY1 3 4 T KEY2 45

Re: Substring and Sort

2002-10-21 Thread Michael Fowler
On Mon, Oct 21, 2002 at 04:32:27PM -0500, Akens, Anthony wrote: [snip] It looks like you forgot -w and use strict. > open (NAMES, $namefile) > or print "Could not open $namefile $!"; Do you really want to continue and read the file if the open fails? > while() > { > ($key, $value

RE: Substring and Sort

2002-10-21 Thread Akens, Anthony
print $displayname; print "<\/a>\n"; } } - -Original Message- From: Larry Coffin [mailto:lc2002@;PointInfinity.com] Sent: Monday, October 21, 2002 2:53 PM To: Akens, Anthony; [EMAIL PROTECTED] Subject: Re: Substring and Sort At 3:03 PM -0400 10/21

Re: Substring and Sort

2002-10-21 Thread Larry Coffin
At 3:03 PM -0400 10/21/02, Akens, Anthony wrote: >I'm attempting to use the following code to read a file >in the format of: > >directory name:displayname > >I want to sort the list by the "displayname", looking >at the first letter for each display name in the file. >If it's unique, I want to prin

Re: Substring and Sort

2002-10-21 Thread david
Anthony Akens wrote: > I'm attempting to use the following code to read a file > in the format of: > > directory name:displayname > > I want to sort the list by the "displayname", looking > at the first letter for each display name in the file. > If it's unique, I want to print it. This should

Re: substring replacement

2001-06-21 Thread Mark Bedish
On 20/6/01 at 3:44 pm, [EMAIL PROTECTED] (Michael Fowler) wrote: Thank for your help, I'll try some of it out and let you know. The data comes from a mainframe system and going to be loaded into MS SQL Server database. I am really impressed by Perl, it can do easy things so quickly. > > > my @

Re: substring replacement

2001-06-21 Thread Michael Fowler
On Thu, Jun 21, 2001 at 08:29:05PM +0100, Mark Bedish wrote: > I am putting tabs between the fields and then changing the a13 which is > a tso overpunch to its decimal equiv, e.g. 1234} means -123.40 . How.. odd. > As I hinted, my code is very procedural as I am not used to Perl yet. Procedur

Re: substring replacement

2001-06-20 Thread Michael Fowler
On Wed, Jun 20, 2001 at 11:41:29PM +0100, Mark Bedish wrote: > I am using substrings in a screipt and wondered if there was a better > perlish way to do it. I am taking data from a mainframe system and > reformatting it but the substring seems to be quite slow, like visual > basic, the original. >

Re: Substring retrieval

2001-06-06 Thread Will W
- Original Message - From: Hasanuddin Tamir <[EMAIL PROTECTED]> To: Nathaniel Mallet <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 05, 2001 8:38 PM Subject: Re: Substring retrieval > On Tue, 5 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]

Re: Substring retrieval

2001-06-05 Thread Hasanuddin Tamir
On Tue, 5 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]> wrote, > The Index function isn't listed on the perl.com website, which was the only > place I looked for documentation up until now. I haven't recieved my Perl > books from Fatbrain yet. ;-) It's always right there (among other functions

Re: Substring retrieval

2001-06-05 Thread Nathaniel Mallet
t; <[EMAIL PROTECTED]> To: "Nathaniel Mallet" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Monday, June 04, 2001 10:21 PM Subject: Re: Substring retrieval > On Mon, 4 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]> wrote, > > > Date: Mon, 4 Ju

Re: Substring retrieval

2001-06-05 Thread Carl Rogers
Good day; At 08:17 AM 6/5/2001 -0700, Paul wrote: >--- Nathaniel Mallet <[EMAIL PROTECTED]> wrote: > > Hi, > > > > I'm trying to retrieve a substring from a string, but I'm not > > sure exactly where and how big that substring is. The substring is > > delimited by a start and end special char

Re: Substring retrieval

2001-06-05 Thread Paul
--- Nathaniel Mallet <[EMAIL PROTECTED]> wrote: > Hi, > > I'm trying to retrieve a substring from a string, but I'm not > sure exactly where and how big that substring is. The substring is > delimited by a start and end special character. It was suggested to > me to write two regular express

Re: Substring retrieval

2001-06-04 Thread Hasanuddin Tamir
On Mon, 4 Jun 2001, Nathaniel Mallet <[EMAIL PROTECTED]> wrote, > Date: Mon, 4 Jun 2001 21:06:43 -0400 > From: Nathaniel Mallet <[EMAIL PROTECTED]> > To: [EMAIL PROTECTED] > Subject: Substring retrieval > > Hi, > > I'm trying to retrieve a substring from a string, but I'm not sure > exact

Re: Substring retrieval

2001-06-04 Thread Eduard Grinvald
Ok, the best way (in my opinion), would be, assuming 's' and 'e' are the start/end special characters: $string =~ s/^.*?(s.*e).*$/$1/; - Original Message - From: "Nathaniel Mallet" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, June 04, 2001 9:06 PM Subject: Substring retrieval