I knew I shouldnt have abreviated the string.
here is the string sorry I kinda flubbed on the last string
"Location||||||||Campus~\\\\\\\\\\n-----\nName||||||||Bob
Williams~\\\\\\\\\\n-----\nAddress||||||||123 Main St~\\\\\\\\\\n-----\n..."
the ... is a very long list.
how does this change the preg_match
"M. Sokolewicz" <[EMAIL PROTECTED]> wrote:
Not sure what you want exactly, but here's a way using regexps to
retrieve the strings seperatly:
$string = 'Campus||||||||Bob (Williams)~\\\\\\\\\toms more
crap)~\\\\\\\\\blah blah blah)~\\\\\\\\\';
preg_match('#([^|]*)[|]+([^|]*)~[\]+([^\]*)~[\]+([^\]*)~[\]+#Ui',
$string, $res);
$campus = $res[1];
$bob = $res[2];
$crap = $res[3];
$blah = $res[4];
?>
Now, if you wanted the positions... then something like this would work:
$string = 'Campus||||||||Bob (Williams)~\\\\\\\\\toms more
crap)~\\\\\\\\\blah blah blah)~\\\\\\\\\';
preg_match('#([^|]*)[|]+([^|]*)~[\]+([^\]*)~[\]+([^\]*)~[\]+#Ui',
$string, $res);
$campus = strpos($string, $res[1]);
$bob = strpos($string, $res[2]);
$crap = strpos($string, $res[3]);
$blah = strpos($string, $res[4]);
?>
Dan McCullough wrote:
> Hey everyone
>
> Having a bit of trouble with something.
>
> I have a string which has known patterns.
>
> $string"Campus||||||||Bob (Williams)~\\\\\\\\\toms more crap)~\\\\\\\\\blah blah
> blah)~\\\\\\\\\";
>
> What I am looking for is
>
> Location which is Campus
> Location Name which is Bob (Williams)
>
> Help?
>
>
>
> ---------------------------------
> Do you Yahoo!?
> vote.yahoo.com - Register online to vote today!
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--------------------------------------------------------
"Theres no such thing as a problem unless the servers are on fire!"
---------------------------------
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.