© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
88 replies
Chris TCC

❔ trim string according to regex

I've got this regex string,
^(?:\b\w+\b[\s\r\n]*){1,25}$
^(?:\b\w+\b[\s\r\n]*){1,25}$
which is supposed to verify the string doesn't have more than 25 words.
How do I use this regex (or modifications of it) to trim the string to 25 words if it's longer than that? (when the regex check fails)
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?
Next page

Similar Threads

✅ how do i trim this string
C#CC# / help
4y ago
❔ Regex to find string between _ or next uppercase letter
C#CC# / help
4y ago
✅ Replace regex-pattern with dynamically generated string.
C#CC# / help
3y ago
❔ Sort dictionary according to the list of string (sorted keys)
C#CC# / help
4y ago