PHP Server Side Scripting Forum

I am trying to create a simple function, maybe using Regular Expressions, that would let me search text for a substring of continuous characters. For example, I don't want a word or URL etc. to exceed 25 characters in length. The most important thing is that the string is identified and replaced.

Example: $str = "this is a simple string of cxdhbnmkgfhgfsa/:$&@xxstrehxvifdsa that I want to check";

I want to be able to locate the long substring within $str and replace it with something else. Any help will be appreciated.