0

Hello. I have a string that im trying to pull text from. But I want it to pull the text between certain points. Is this possible?

For Example:

DABHolly,BuddyDAL1466 N Scooby AveDAIAtlantaDACGADAQ

=========================== =========

Is there a script that can pull the text between DAB & DAL, DAL & DAI, DAI & DAC, etc.

Im trying to extract "Holly, Buddy", "1466 N Scooby Ave", "Atlanta", and "GA"

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by scaiferw
0

You can use regular expressions. Every language I know of either has an implementation of it, or can use a library to do it.

0

Or you could try something like this:

$source = "DABHolly,BuddyDAL1466 N Scooby AveDAIAtlantaDACGADAQ";

$name_start	= strpos($source,"DAB")+3;
$name_end 	= strpos($source,"DAL");
$name 		= substr($source,$name_start,$name_end - $name_start);

$addr_start	= strpos($source,"DAL")+3;
$addr_end 	= strpos($source,"DAI");
$addr 		= substr($source,$addr_start,$addr_end - $addr_start);

$city_start	= strpos($source,"DAI")+3;
$city_end 	= strpos($source,"DAC");
$city 		= substr($source,$city_start,$city_end - $city_start);

$state_start	= strpos($source,"DAC")+3;
$state_end 	= strpos($source,"DAQ");
$state 		= substr($source,$state_start,$state_end - $state_start);

echo "<p>Name: $name</p>";
echo "<p>Addr: $addr</p>";
echo "<p>City: $city</p>";
echo "<p>State: $state</p>";
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.