<# *********************************************************************************************************** This module contains some common text handling modules. Version: 1.0 Author: Ira Babb Date: 06-15-2013 *********************************************************************************************************** #> ########################################################################################################### Function ParseLine ($Line, $StartPosition, $PrimaryBreakCharacter, $AlternateBreakCharacter) # ######################################################################################********************************************************* #This function is passed a string, a position in the string to start and two characters on which if #encountered the processing of the string will stop. This is used to extract information from a messy #and/or inconsistent string. #Essentially you pass it a string and tell it where you want it to stop and on what character (up to two) #you want it to stop. It will return all the characters between where you told it to start and the stop #character, not including the stop character. It also returns the position in the string where it #encountered the stop character. ######################################################################################********************************************************* #> { $ResultArray=@("string",2) $CurrentLine = 0 $LineLength = $Line.Length - 1 for ($ParseLoop = $StartPosition; $ParseLoop -le $LineLength; $ParseLoop++) { If ($Line[$ParseLoop] -eq $PrimaryBreakCharacter -or $Line[$ParseLoop] -eq $AlternateBreakCharacter) { $CurrentLine = $ParseLoop $ParseLoop = $LineLength } Else { $PrimaryValue += $Line[$ParseLoop] } } #Push the character array into a string #Why not use -join? PS1 foreach ($Character in $PrimaryValue) {$EndString+=$Character} $ResultArray[0] = $PrimaryValue $ResultArray[1] = [int]$CurrentLine Return $ResultArray } ###########################################################################################################