Regular Expressions 101

Community Patterns

Truncate words to only 2 first characters of the word

0

Regular Expression
ECMAScript (JavaScript)

/
(\w{2}).*?\b
/
gm

Description

It grabs 2 first characters from a word. So:

  • please will be pl
  • sure and sun will be su
  • white and what will be wh

Go to substitute mode for the result to appear :)

Submitted by anonymous - 2 years ago