Site icon Hip-Hop Website Design and Development

How to dynamically parse and transform post/page content before displaying it?

I have several posts where part of the displayed content will depend on several conditions.
I am thinking on creating a custom html tag. Then, before displaying the post content,
the conditions will be checked by running a script in the background . Finally the appropriate content will be displayed by replacing the tag with data retrieved from a database.

What is the best way to do this pre-processing with wordpress? Are they specific hooks allowing to get access to the post before displaying it?

example:

TEXT

custom html

TEXT