Advertisement
Guest User

Pad middle column

a guest
Apr 26th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $sampleText = "A/R                                      Patient                                  TIKASI, DEREK  00000000             00000000             Inpatient                                "
  2. $maxLength = 1500
  3.  
  4. $firstDigitPosition = [regex]::match($sampleText,"\d").Index
  5.  
  6. $padChar = " "
  7. $padding = $padChar * ($maxLength - $sampleText.Length)
  8.  
  9. $finalRow = $sampleText.Substring(0,$firstDigitPosition - 1) + `
  10.                 $padding + `
  11.                 $sampleText.Substring($firstDigitPosition - 1,$sampleText.Length - $firstDigitPosition + 1)
  12.  
  13. $finalRow
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement