Announcement

Collapse
No announcement yet.

Regular expressions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regular expressions

    Hello,
    Can somebody please explain these to me??

    I can't find very much about them in the PHP manual.


    Thanks,
    Dennis
    Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

    PHP 4.0.6
    MySQL 3.23.39
    Windows 2000

  • #2
    http://www.php.net/distributions/big....html#ref.pcre
    http://www.php.net/distributions/big...html#ref.regex
    Ryan "leadZERO" Sommers
    Gamer's Impact President
    [email protected]
    ICQ: 1019590
    AIM/MSN: leadZERO

    -= http://www.gamersimpact.com =-

    Comment


    • #3
      Thanks, but I still don't completely understand them...

      I mean.. how do you use them??

      I know how to use ^ and $... but thats it..


      Thanks,
      Dennis
      Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

      PHP 4.0.6
      MySQL 3.23.39
      Windows 2000

      Comment


      • #4
        There's a tutorial on PHPBuilder: http://www.phpbuilder.com/columns/dario19990616.php3

        Basic stuff: anything inside ( )'s will be returned for use in the replace part (via \\1, \\2, etc)
        . means any character
        * means 0 or more of the previous
        + means 1 or more of the previous

        then after the closing delimiter

        Code:
        $result = preg_replace("/vBoard/flags","vBulletin",$string);
        s means search
        i means case insensitive
        U means ungreedy.

        (if U isn't specified:
        /<i>(.*)</i>/
        will match the first <i> and the last </i>
        with U, it'll function correctly)

        Comment


        • #5
          thanks... but what are the / / for?

          and what does "Ungreedy" do??

          and how do you use s?



          Thanks,
          Dennis

          PS:

          That tutorial on PHP Builder was a little confusing.
          Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

          PHP 4.0.6
          MySQL 3.23.39
          Windows 2000

          Comment


          • #6
            The outside / /'s are just enclosing the expression, and they can actually be any of a set of characters.
            Ryan "leadZERO" Sommers
            Gamer's Impact President
            [email protected]
            ICQ: 1019590
            AIM/MSN: leadZERO

            -= http://www.gamersimpact.com =-

            Comment


            • #7
              Thanks
              Visual Basic, HTML, PHP, SQL, ASP, JavaScript, C++, Perl

              PHP 4.0.6
              MySQL 3.23.39
              Windows 2000

              Comment


              • #8
                Originally posted by JohnM
                (if U isn't specified:
                /<i>(.*)</i>/
                will match the first <i> and the last </i>
                with U, it'll function correctly)

                Comment

                widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                Working...
                X