Uli & others, Thanx for the suggestions. This works as stated but the data already exists in this format from an old database and I'm trying to parse it into logical fields. Originally the data in the field looked something like 1$General/ms1.zip#12$Another/xqy.zip#. I deleted the ending # then used explode to separate the information on the # and now I need to separate the info before the $ from what comes after it. I've tried everyone's suggestions but they only work if I'm testing and can define the string using single quotes.
How can I split on a $ or change the $ to something else if I'm getting the information from a database (MySQL), not defining it using single quotes like in your example? Bev -----Original Message----- From: Uli B [mailto:[EMAIL PROTECTED]] Sent: Saturday, June 29, 2002 11:56 AM To: PHP List Subject: Re: [PHP] need to change $ char in string use single quotes: double quotes would confuse php with variable names. it thinks that $General is a variable and replace it by it's empty content. single quotes prevent php from evaluating the string: $test_string = '1.2$General/ms1.zip'; single quotes on regex too (same reason). the backslash in this case (\$) refers to perl regular expression syntax but does not take care of php ! $new_string = preg_replace('/\$/', "%", $test_string); ub At 10:58 29.06.02 -0400, Beverly Steiner wrote: >I've tried everything I can think of to change a dallar sign in a string to >something else or to split the string on the $ but I can't the the >information that comes after the $. > >Typical string contains: 1.2$General/ms1.zip > >when I try: > $new_string = preg_replace("/\$/", "%", $test_string); > >or (trying to avoid specifying the $): > $new_string = preg_replace("/(\d\.\d{1,2})\D(\w.*$)/", "\1%\2", >$test_string); > >echo "new_string is $new_string"; prints new_string is 1.2 > >Has anyone solved this problem? > >Thanx, > >Bev > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php -- ----------------------------------------------- Ulrich Borchers Brandenberger Straße 18, 41065 Mönchengladbach fon +49-2161-175883 icq 1282868 ----------------------------------------------- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php