Newbie
Newbie

Reputation: 167

How to insert hyphen after third character

I want to remove the first three characters of the string and insert a hyphen between 3rd and 4th of the remaining 6 characters. For example Input:

123456789

Output:

456-789

My regular expression removes the first three characters, but I'm not sure how to insert hyphen.

(^.{3})(\w+) $2

Upvotes: 3

Views: 3695

Answers (1)

ndnenkov
ndnenkov

Reputation: 36101

^.{3}(.{3})(.*)

replace with:

$1-$2

See it in action

Upvotes: 8

Related Questions