How to maintain specific length for each word usin

2019-08-19 12:40发布

问题:

I have three words in each line separted by dot.

Word1.Word2.Word3
Example1.Example2.Example3

Here are the three words but each word must be of specific length. Word1 must be of 10 characters, Word2 must be of 10 characters, Word3 must be of 16 characters. If any word is less than specific lenght of characters, it must be filled with spaces. So, it must be look like this -

Word1     .Word2     .Word3          
Example1  .Example2  .Example3       

How can i check the words and fill up with spaces if not met with specific length with regexp in Notepad++ ?

回答1:

I would do it by adding lots of extra spaces, then removing excess ones.

  1. Replace regex \. with __________. (I'm writing _ instead of spaces because stackoverflow doesn't display leading and trailing spaces, but you should use spaces.)
  2. Replace regex $ with ________________
  3. Replace regex ([^.]{10})[^.]*\. with $1.
  4. Replace regex ([^.]{16})[^.]*$ with $1