Quote Originally Posted by Brainer
That's right. It shouldn't be too difficult to create one yourself. I suggested writing one 'cause I was thinking about creating such thing for some future works.

Actually, converting this one to Delphi doesn't look like too much work, especially when you have some code to parse regular expressions.

On the other hand, an event-driven class would be the perfect solution, i.e. if the parser finds the "img" tag, it fires an OnBeginTag event and passes the name and its attributes to the event. The declaration could look like the following:
[code=delphi]
type
{ .: TBBCodeTagType :. }
TBBCodeTagType = (tagColor, tagBold, tagItalic, tagImage);

{ .: TTagEvent :. }
TTagEvent = procedure(Tag: TBBCodeTagType; const Attribute: AnsiString) of object;

{ .: TBBCodeParser :. }
TBBCodeParser = class sealed(TObject)
// Some other code here
public
{ Public declarations }
function Parse(const TextToParse: String): Boolean;

property OnBeginTag: TTagEvent read FOnBeginTag write FOnBeginTag;
property OnEndTag: TTagEvent read FOnEndTag write FOnEndTag;
end;

{ ... }

function TBBCodeParser.Parse(const TextToParse: String): Boolean;
var
FoundTag, TagAttr: String;
begin
Result := False;
FoundTag := '';
TagAttr := '';

// .. Some code here ..
if Assigned(FOnBeginTag) then
begin
if (FoundTag = 'color') then
FOnBeginTag(tagColor, TagAttr);
// and so on
end;
end;
[/code]
Nice idea Patrick, you make me want to start right now! LOL

cheers,
Paul