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.

Thanks,
Ethan

Why not just do:

if(strlen($str) > 25)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.