Ready for regular expressions Dec20 '04

No fear

I am currently looking for some good resources (help!), or tips on using regular expressions in PHP.

I have heard many grave things about regular expressions, from developers of Java and ASP.net. It seems it takes a certain ability and keen awareness to even have the sheer patience to work with regular expressions.

Many have laughed at my interest and desire to learn regular expressions.

I, however, am not afraid. I want to face this "head on." I want regular expressions to become a powerful tool in my "web scripting toolkit."

Reasons for my desire

The main reason I am looking to use regular expressions is for database storage situations.

For some scenarios, I store HTML in database tables, and I know this is NOT good practice. I do this because string column types (in SQL), namely mediumtext and larger, usually contain more than a single paragraph. And... if there are no <p> </p> tags designating the start and finish of the paragraphs within the database table, how would the browser know that I want more than a single paragraph to be presented in HTML?

This goes for HTML lists (<ul>, <ol>), as well.

Within a body of a document, paragraphs and lists are always present. And the body is usually stored in a single database table.

That means either the HTML goes in with it, or a regular expression is used to determine which "segments of text" need HTML tags surrounding them.

Why does it matter?

When you include HTML elements in a database table, you "hard code" the format, which inhibits future changes.

Also, I firmly believe in separating content from formatting. Just like content is separated from presentation with CSS, formatting should be distinctly separate, as well.

Conclusion

So... if you have any tips, resources, or advice – please share. I need to get some answers (and results) fast.

I need to make the changes, and stop these bad habits soon.

Categories: Programming , Web Development

Add Feedback (view all)

Leave feedback

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

I think storing HTML in the database is good. Although not everything. You can convert new lines (\n) to using a cool script fro ... Read more.

Dale, cool. You make a good point. After all, there is no harm in storing the HTML in the database, because if I want it removed, I can just use a ... Read more.

Mmm formatting is a good question. You COULD write a bb-like-code thing to do div styles. So [quote]bla[/quote] which then gets converted t ... Read more.

Dale, good enough. Thanks for your input. ... Read more.

matthom is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago. Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.

Contact Matt

Similar Entries

Stats

0 unique visits since Dec20 '04

Recent Referrers (click)

Syndicate

Advertisements