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!
Have you tried this? I'm not sure if it'll work or not.
Yep. Tried it and didn't work. Perhaps its because of the linebreaks or the squared brackets? Does anybody have a solutiion? :)
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?
Can you be more specific? For example, can you give:
[ul][li]The regular expression you're using.
[li]An example of some text you'd like to match.
[li]What your expression is matching instead.[/ul]
Your description is, I'm afraid, too general.
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.
the form of the expression is
string ereg_replace(string pattern, string replacement, string text)
for my problem i had to convert the address to a usable form with the expression. mysql gave me $row["address"].
so it became:
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.