English Русский Deutsch Български Français Español

Demos

Demo code for TRegExpr

Introduction

If you don’t familiar with regular expression, please, take a look at the r.e.syntax.

TRegExpr interface described in TRegExpr interface.

Text2HTML

Text2HTML sources

Publish plain text as HTML

Uses unit HyperLinksDecorator that is based on TRegExpr.

This unit contains functions to decorate hyper-links.

For example, replaces www.masterAndrey.com with <a href="http://www.masterAndrey.com">www.masterAndrey.com</a> or filbert@yandex.ru with <a href="mailto:filbert@yandex.ru">filbert@yandex.ru</a>.

function DecorateURLs (
    const AText : string;
    AFlags : TDecorateURLsFlagSet = [durlAddr, durlPath]
) : string;

type
TDecorateURLsFlags = (
    durlProto, durlAddr, durlPort, durlPath, durlBMark, durlParam);

TDecorateURLsFlagSet = set of TDecorateURLsFlags;

function DecorateEMails (const AText : string) : string;
Value Meaning
durlProto Protocol (like ftp:// or http://)
durlAddr TCP address or domain name (like masterAndrey.com)
durlPort Port number if specified (like :8080)
durlPath Path to document (like index.html)
durlBMark Book mark (like #mark)
durlParam URL params (like ?ID=2&User=13)

Returns input text AText with decorated hyper links.

AFlags describes, which parts of hyper-link must be included into visible part of the link.

For example, if AFlags is [durlAddr] then hyper link www.masterAndrey.com/contacts.htm will be decorated as <a href="www.masterAndrey.com/contacts.htm">www.masterAndrey.com</a>.

TRegExprRoutines

Very simple examples, see comments inside the unit

TRegExprClass

Slightly more complex examples, see comments inside the unit