记事本++:删除字符串中多个字符后的所有内容

Notepad++: Delete everything after a number of characters in string

下面是Notepadd++中每行24个字符的例子。我需要将每行字符限制为 14 个字符。

Hell, how is she today ?

我需要它看起来像下面这样:

Hell, how is

我使用了这个代码

Find what: ^(.{1,14}).*
Replace with: 

但是显示"Hell, how is s",拼错了。

如何在 Notepad++ 中将字符数限制为每行 14 个字符并删除最后一个字?

是你想要的吗:

查找内容:^(.{1,14}) .*$
替换为:

如果 space.

这将截断为 14 个字符或更少

这应该适合你:

查找内容:^(.{1,14}(?<=\S)\b).*$

替换为:</code></p> <p>所以对于 <code>Hell, how is she today ? 输出是:Hell, how is

DEMO

^                # The beginning of the string
(                # Group and capture to :
  .{1,14}        # Any character except \n (between 1 and 14 times (matching the most amount possible))
  (?<=\S)        # This lookbehind makes sure the last char is not a space
  \b             # The boundary between a word char (\w). It matches the end of a word in this case
)                # End of 
.*$              # Match any char till the end of the line

也可以使用 \K 作为可变长度后视并替换为空:

^.{0,13}\w\b\K.*

\w 匹配 word character, \b a word boundary

Test at regex101.com