[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 768
  • Last Modified:

Regex to Substring without cutting off word

I'm trying to figure out a regex which will act as a substring but not cut off words.  For example, I want to take a substring of 0 to x chars in a description but do not cut off any word.\

so something like give me 0 to x chars but cut off anything that's only one character toward the end type of deal so that I do not end up with a single character or soemthing else at the end of the description.
0
dba123
Asked:
dba123
  • 2
1 Solution
 
ozoCommented:
.{0,x}\b
0
 
ozoCommented:
.{0,x}(?!.$)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now