Re: How to pick out some text for use in a Forum?



On Jul 29, 12:10 pm, 703designs <thomasmal...@xxxxxxxxx> wrote:
I'm writing an extension for some PHP forum software. $String is the
post contents, and I want to do the following to it. Note that I'm not
looking for someone to solve this for me, I'm just not sure what the
best approach is.

1. Find all instances of [code]user post text...[/code]
2. If the lang attribute is supplied, keep track of its value for that
code block, e.g. [code lang="css"]
3. Wrap the contents of the code block in HTML tags with the CSS class
set to lang's value if it was specified
4. Of course, output this new string in the same position as before in
the post

Any ideas? Thanks!

the best way to do it is to use regular expressions to find the "lang"
as well as any text inside the [code][/code] tags.
.



Relevant Pages

  • Re: escape problem ?
    ... The string value of a nodeset is the string value of the ... first node in the nodeset, so you are always testing the first entry ... in $LANG. ...
    (comp.text.xml)
  • Re: File names, character sets and Unicode
    ... Possibly UTF-8 encoded Unicode, who knows. ... For instance zh_TW is BIG5 charset by default, ... via $LANG, there is no guarantee that all file names are encoded this way. ... byte string file name, but keep the byte string for operations on the ...
    (comp.lang.python)
  • Re: reqular expr for string manip.
    ... # Find the part of the string that does not have a slash and is ... $lang of the following string ... But it doesnt seem to work, what am i missing here? ...
    (perl.beginners)
  • Re: reqular expr for string manip.
    ... I am using the following reqular expression to extract the last part ie ... $lang of the following string ... But it doesnt seem to work, ...
    (perl.beginners)