Kenan EROL
Kenan EROL

Reputation: 27

How to insert a character after every x amount(10) of characters on Sublime Text? V3.2.2

word word word word word word word word word word word word word word word word word

insert "&B5&" after every 10 characters, becomes to

word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word

How can I do that with Sublime Text 3 or Notepad++ or else? What is the regex find and replace suggestions? Or any other useful way to do it

Upvotes: 1

Views: 615

Answers (1)

ferhado
ferhado

Reputation: 2604

You can do it using regular expresion, here is an example using vscode: [^.*]{10} replace all with $0 "&B5&"

enter image description here

output:

word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word

note: you can use this regex also for sublime. don't forget to check .* button

enter image description here

or using php:

$input = 'word word word word word word word word word word word word word word word word word';

$input = preg_replace('#([^.*]{10})#', '$1 "&B5&"', $input);

echo $input;

output:

word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word word "&B5&"word

Upvotes: 1

Related Questions