Skip to content

Commit

Permalink
Better string format
Browse files Browse the repository at this point in the history
Updated Format-String to strip punctuation when required
  • Loading branch information
Akaizoku committed Oct 5, 2018
1 parent 7c013d3 commit 8445048
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions PSTK.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1949,10 +1949,11 @@ function Format-String {
.PARAMETER Delimiter
The delimiter parameter corresponds to the character used to delimit dis-
tinct words in the string.
The default delimiter for words is the space character.
The default delimiter for words is the space character
.NOTES
The delimiter for words is the space character.
When the output word delimiter is not a space (i.e. the formatted string is
not a sentence), all punctuation is stripped from the string.
#>
[CmdletBinding ()]
Param (
Expand Down Expand Up @@ -2008,6 +2009,9 @@ function Format-String {
Others = @("CamelCase","PaslcalCase","SentenceCase","TitleCase","TrainCase")
}
# Create array of words
if ($Delimiters.$Format -ne " ") {
$String = $String -replace ("[^A-Za-z0-9\s]", "")
}
$Words = $String.Split($Delimiter)
$Counter = 0
$FormattedWords = New-Object -TypeName System.Collections.ArrayList
Expand Down

0 comments on commit 8445048

Please sign in to comment.