Well, I *can* share what I got working, but it will reveal to the list
how unskilled I am . . .

This is a common example of what I'm seeing:

Von Trapp, Mary Jane L 00045791 01/02/2003 Another string with spaces
1,444.00 15,555.00 YES

Because the data follows a specific pattern, and because the data sets
are relatively small, I realized I could achieve what I wanted w/o
regex (and I've never been intelligent enough to really get regex
anyway).

I split out the parts of the string by looking for a specific
character (or a type of character), and then chopping off the string
preceding that character so that in the next search I wouldn't find
it. Mostly I used strpos() to find a comma or a space, and then a
combination of trim() and substr() to get the new string for
searching. The only mildly tricky part was when I wanted to look for a
number (but not knowing what number, specifically) -- but then I
remembered that you can access a string like an array. So I created a
function which returns the position of the first number in a string:

function findFirstNum ($searchString)
{
        $firstNumPos = false;
        for ($i = 0; $i < strlen($searchString); $i++)
        {
                if (is_numeric($searchString[$i]))
                {
                        $firstNumPos = $i;
                        break;
                }
        }
        return $firstNumPos;
}

It wouldn't take much to make this function behave more like strpos()
-- with offsets and whatnot, but this does everything I needed.

I didn't mention the precise solution, because I asked for and
received help -- and I didn't want to appear ungrateful by not using
that help. I really am thankful for all the responses.

Regards,

Dave

> Could you share what you got working?
>
> Thanks,
>
> Dave

_______________________________________________

UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net

Reply via email to