[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] how can I parse out fax numbers from ad texts? (fwd)



According to Joseph\"ALVIS\"Alexander Snow:
> eg. ad reads: send letter to oweo;fjh f;jldf, or fax:233-645-56434,
> could be send fax to (232)834-9957, etc...
> you get the picture...

Ok, I'm sure someone else has already sent you something.
But here's my $0.02.

After you've gotten your ad/page/etc....  You can do the
following:

	$theFaxFlag = 0;
	$theNumber = "";
	for( $i=0; $i<=$#theAdArray; $i++ ){
		@line1 = split( / /, $theAdArray[$i] );
		for( $j=0; $j<=$#line1; $j++ ){
			if( ($line1[$j] =~ /fax/i) || ($theFaxFlag > 0) ){
				if( $line1[$j] =~ /[0-9]/ ){
					$theFaxFlag = 0;
					if( $line1[$j] =~ /:|=/ ){
						@line2 = split( /:|=/, $line1[$j] );
						for( $k=0; $k<=$#line2; $k++ ){
							if( $line2[$k] =~ /0-9/ ){
								$theNumber = $line2[$k];
								}
							}
						}
					}
					else {
						$theFaxFlag = 1;
						}
				}
			}
		}

This is just off the top of my head and does not include
how to read in or print out the phone number.  That's
something you want to personalize.  And there might be
errors in the above.  But at least it's a start.  :-)

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch