I'm having some problems finding a regular expression. It sounds very simple but I couldn't get anything to work. What I want is an eregi_replace (in PHP) that will find any characters including [ and ] and linebreaks. In another words a regular expression that will find anything (don't worry much about symbols). I won't use many symbols but the square brackets are essential. Thanks!
Ah, It must be because of the squared brackets and it didn't work. I have tried \[ and \] but for some reason it doesn't work. Anybody know why the backslash doesn't seem to be doing anything?
in the leon atkinson book "Core PHP Programming", he says "the eregi_replace function operates identically to ereg_replace with the exception that letters are matched with no regard for upper- or lowercase. "
i used the ereg_replace to find and replace some spaces the spaces in an address string with + so i could use the maps from Yahoo. I already had the address in the form of 123 Front Street and needed 123+Front+Street.
for my problem i had to convert the address to a usable form with the expression. mysql gave me $row["address"].
so it became:
$address=$row["address"];
then it was just a matter of using the expression where i neeeded the 'stuffed address' in the following form.
echo(ereg_replace(" ", "+", $address));
this is a piece of actual working code. does exactly what it is supposed to - finds a blank space in the string $address and replaces the blank space with a +.
but please give more detail to the question. i really need as much experience with regular expressions as i can get.
Bookmarks