SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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!

  2. #2
    Destiny Manager Plebius's Avatar
    Join Date
    Nov 1999
    Posts
    682
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you tried this? I'm not sure if it'll work or not.

    .*

  3. #3
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep. Tried it and didn't work. Perhaps its because of the linebreaks or the squared brackets? Does anybody have a solutiion?

  4. #4
    ********* Addict
    Join Date
    Apr 2000
    Location
    Posts
    272
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  5. #5
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    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.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  6. #6
    SitePoint Wizard edshuck's Avatar
    Join Date
    Jul 2000
    Posts
    1,200
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi

    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:

    $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.

    thanks ed



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •