Results 1 to 6 of 6

Thread: Text parsing and replacement. php5

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Text parsing and replacement. php5

    Totally lost on how to do this but figure it's via one or more of the string functions.

    Am adding in bbcode tags to an articles management system and so far pretty easy to do bold, underline, strike out, etc.

    Having problems getting an article link thing to work.

    What I would like to do is tag up titles appearing in articles, then when the article is parsed the software will check if another article exists in the datebase and replace the bbcode with a link to the other article.

    Something like


    Considering the similarities to Miike's [ m ] Imprint [ /m ] one is left with the only conclusion being ....
    So "Imprint" is seen as an article title, due to the [ m ] tag (spaces inserted just in case vB's parser does something with them), when it comes time to display this article, the software takes "Imprint" checks if an article of that name exists in the db, if it does then the software replaces the "[ m ] Imprint [ /m ]" with a link to the "Imprint" article, if it doesn't the [ m ] tags are simply removed. Oh and articles can of course have multiple words in their title.

    Hopefully that all make's some sort of sense

    Thanks in advance.

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Text parsing and replacement. php5

    What part are you having trouble with? The tag checking? The tag adding to articles? The tag replacement?


    Has someone helped you? Then you can Rate their helpful post.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: Text parsing and replacement. php5

    Quote Originally Posted by manavo11
    What part are you having trouble with? The tag checking? The tag adding to articles? The tag replacement?
    The tag replacement with a url link.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Text parsing and replacement. php5

    What do you have so far? Are you using a simple string replace to change the tags to HTML? Regular expressions?

    Have a look at this :

    http://www.vbforums.com/showthread.p...ar+expressions


    Has someone helped you? Then you can Rate their helpful post.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2007
    Location
    Godzone, oops Oz
    Posts
    355

    Re: Text parsing and replacement. php5

    Quote Originally Posted by manavo11
    What do you have so far? Are you using a simple string replace to change the tags to HTML? Regular expressions?

    Have a look at this :

    http://www.vbforums.com/showthread.p...ar+expressions
    Am using the preg_replace function and have bold, italic, and strike-out working but am unsure if I can take the same approach with urls as it will need to search for the title on the database, work out the url extension before converting the tags.

    At this stage just toying with the idea, trying to get it to work, and then seeing the impact on a db with a few hundred records.

  6. #6
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Text parsing and replacement. php5

    You can use the preg_replace_callback() function. You can have your checking code in here. I would advise you do this on input rather than during the display process.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width