rch10007
04-08-2006, 01:31 AM
I have a file that uses @ as a delimiter. I am trying to change the string before the first delimiter only.
The lines in the file look like this:
sometext123@moretext456@moretext
sometext123@moretext456@moretext
sometext123@moretext456@moretext
....
What I am trying to do is eliminate the letters before the first @, so the resulting lines look like:
123@moretext456@moretext
123@moretext456@moretext
123@moretext456@moretext
....
this is what I have tried using and it doesn't work!
foreach($text as $line)
{
fwrite($fh, preg_replace('/^[A-Za-z]@$/', '', $line));
}
note* assume i have the file open adn its readable.
also, why is what I have not working - i really am trying to get PCRE but it is so confusing!!
^ = start searching at the beggining right?
[A-Za-z]@ = thsi is the pattern i am looking for
$ = stop searching this line??
'' = replace it with nothing
is this not correct (i guess so, but how)?
thanks
The lines in the file look like this:
sometext123@moretext456@moretext
sometext123@moretext456@moretext
sometext123@moretext456@moretext
....
What I am trying to do is eliminate the letters before the first @, so the resulting lines look like:
123@moretext456@moretext
123@moretext456@moretext
123@moretext456@moretext
....
this is what I have tried using and it doesn't work!
foreach($text as $line)
{
fwrite($fh, preg_replace('/^[A-Za-z]@$/', '', $line));
}
note* assume i have the file open adn its readable.
also, why is what I have not working - i really am trying to get PCRE but it is so confusing!!
^ = start searching at the beggining right?
[A-Za-z]@ = thsi is the pattern i am looking for
$ = stop searching this line??
'' = replace it with nothing
is this not correct (i guess so, but how)?
thanks