Hi guys,
can you use preg_match() to test for a string length instead of using the strlength()
string length regular expression
Moderator: General Moderators
I only answered your question as asked.kendall wrote:was hoping to get a pattern example...i knew that already...Zoxive wrote:Yes, but str_len would be alot faster.
"Word Character" up to 10 characters long.
Code: Select all
^[\w]{0,10}$Code: Select all
// for educational purposes only
preg_match('/^.{5}$/sD', 'abcde');- kendall
- Forum Regular
- Posts: 852
- Joined: Tue Jul 30, 2002 10:21 am
- Location: Trinidad, West Indies
- Contact:
hmmmm....neat!GeertDD wrote:Since a string can contain any character, not just word characters, use the dot metacharacter. Also apply the s modifier to make the dot match newlines as well.Code: Select all
// for educational purposes only preg_match('/^.{5}$/sD', 'abcde');
This has just been bugging me... and it's not an answer to the original post... but maybe it's because I'm a stickler. 
The function is strlen(). Not str_len() or strlength().

The function is strlen(). Not str_len() or strlength().
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.