RE: How to substract words

2003-01-08 Thread Meidling, Keith, CTR, OSD-C3I
This may be oversimplified, but here's what I came up with and it worked for me... $word1="helloRed"; $word2="hello"; $word1 =~ /$word2(.+)/; print $1; This would be assuming that the word you are subtracting is at the beginning of the other word. Keith -Original Message- From: Alex

Re: How to substract words

2003-01-07 Thread R. Joseph Newton
With a minor correction: [or three or four--that was definitely posted in haste] so that it runs: #!/usr/bin/perl -w use strict; use warnings; my $word1 = "Hello"; my $word2 = "Othello's World"; my $result = difference($word1, $word2); print "$result\n"; sub difference { my ($word1, $word2) =

Re: How to substract words

2003-01-07 Thread R. Joseph Newton
Hi John, Hmmm, I don't know about this handing ready-made code out, but--what the hell, the harms been done, so I';ll join the party: #!/usr/bin/perl -w use strict; use warnings; my $word1 = "Hello"; my $word2 = HelloWorld; sub difference { my ($word1, $word2) = @_; if ($word1 =~ /.*$word2.

Re: How to substract words

2003-01-07 Thread R. Joseph Newton
Hi Alex, Can you show or tell us what you have tried? We could also help more if yoiu tell us a little about the subject matter you are covering in class. Alex Demmler wrote: > Hi folks! > > I have a problem with pattern matching. > I want do find the difference between two words. I have tried

Re: How to substract words

2003-01-07 Thread John W. Krahn
Alex Demmler wrote: > > Hi folks! Hello, > I have a problem with pattern matching. > I want do find the difference between two words. I have tried, but donot get > it work. Any tips? > > Example: > > 1. Word = helloRed > 2. Word = hello > --- > Result = Red my $word1 = 'hello

Re: How to substract words

2003-01-07 Thread Dave K
$ perl -e ' $minuend = 'red'; $subtra = 'Hellored'; $res = $subtra =~ s/$minuend//; print $minuend, "\t", $subtra, "\t", $res;' red Hello 1 $res flags success/fail. If you would like $subtra to remain unchanged assign $dif = $subtra then $res = $dif =~ s/$minuend//; HTH "Pavle Lukic" <[EMAI

Re: How to substract words

2003-01-07 Thread Pavle Lukic
Alex This is one way to resolve the issue: $x = substr($a,0,index($a,$b)).substr($a,index($a,$b)+length($b)); I would like to see a solution in terms of regex. Cheers Pavle - Original Message - From: "Alex Demmler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 06, 2