Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以在 Powershell 中使用正则表达式在数组中的项目之后添加空格,以便每个项目的字符长度等于 15?
Dog[12 spaces] Tiger[10 spaces] Elephant[7 spaces]
谢谢。
您可以使用以下PadRight方法:
PadRight
"Dog".PadRight(15, ' ')
http://msdn.microsoft.com/en-us/library/36f2hz3a.aspx
您还可以使用格式字符串,使用正数填充 letf:
'{0,-15}' -f 'dog'