Regex

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Nielsen-Lönn

    #1

    Regex

    Hi!

    I am making a website with PHP (of course) and have to make this
    transformation: <l>name</l> to <a href="blabla.ph p?id=name">name </a>
    How do I do that? Will I have to use several regex or is it possible that I
    can use only one?

    --


    Greetings/Martin Nielsen-Lönn


  • Paul Wellner Bou

    #2
    Re: Regex



    Martin Nielsen-Lönn wrote:[color=blue]
    > I am making a website with PHP (of course) and have to make this
    > transformation: <l>name</l> to <a href="blabla.ph p?id=name">name </a>
    > How do I do that?[/color]

    preg_replace("/<l>(.*?)<\/l>/" "<a
    href=\"blabla.p hp?id=$1\">$1</a>",$str);

    (simple solution, accepts all characters in 'name'.)

    Saludo
    Paul.

    Comment

    • B. Johannessen

      #3
      [OT] XHTML 2 (Was: Regex)

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Martin Nielsen-Lönn wrote:[color=blue]
      > I am making a website with PHP (of course) and have to make this
      > transformation: <l>name</l> to <a href="blabla.ph p?id=name">name </a>[/color]

      If you are going to create your own HTML like markup, you may want
      to avoid using the <l/> element for links. XHTML 2 defines this to
      represent a semantic line (structured replacement for <br/>). See:

      http://www.w3.org/TR/xhtml2/mod-inli...t.html#sec_9.7.


      Bob




      -----BEGIN PGP SIGNATURE-----
      Comment: B. Johannessen <bob@db.org> - http://db.org/contact/en/

      iD8DBQFAQbyBooi sUyMOFlgRAhA4AK CFScrkfQeplpVwn U3XucUUl9bAGACg jTpJ
      N/XF9g9pZNR2U7+KF 5HZCEk=
      =cx7/
      -----END PGP SIGNATURE-----

      Comment

      Working...