-
Notifications
You must be signed in to change notification settings - Fork 1
Split‑StringAtIndex
Splits a string at a specified index or range of indices.
Split-StringAtIndex -IndexObject <PSObject> -InputString <String>
[<CommonParameters>]
Split-StringAtIndex -InputString <String> -StartIndex <UInt32> -EndIndex <UInt32>
[<CommonParameters>]
The Split-StringAtIndex function splits a given string at a specified index or range of indices. It can be used to extract substrings from a larger string based on the provided indices.
Split-StringAtIndex -InputString "Hello, World!" -StartIndex 0 -EndIndex 4
This example splits the input string "Hello, World!" at the index specified by StartIndex and then at the index specified by EndIndex and returns the resulting array of substrings.
@(@{Start = 0; End = 2}, @{Start = 7; End = 11 }) | Split-StringAtIndex -InputString "Hello, world!"
This example splits the input string "Hello, World!" at the indices provided by the pipeline. It will split the string at each StartIndex and EndIndex and returns the resulting array of substrings.
@(0, 1, 2, 7, 8, 9, 10, 11) | Get-NumericalSequence | Split-StringAtIndex -InputString "Hello, world!"
This example splits the input string "Hello, World!" at the indices provided by the pipeline. It will split the string at each StartIndex and EndIndex and returns the resulting array of substrings.
Specifies the ending index of the substring to be extracted. The value must be less than the length of the input string.
Type: UInt32
Parameter Sets: StartEndInput
Aliases:
Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the index object to split the string. This parameter is used when providing input via the pipeline.
Type: PSObject
Parameter Sets: PipelineInput
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseSpecifies the input string to be split.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the starting index of the substring to be extracted. The value must be less than the length of the input string.
Type: UInt32
Parameter Sets: StartEndInput
Aliases:
Required: True
Position: Named
Default value: 0
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
The Split-StringAtIndex function is designed to split strings based on indices and can be used in various scenarios where string manipulation is required. To get the indices the function Get-NumericalSequence can be used.
- Assert-GitLocalChange
- Assert-GitRemote
- Assert-IPv4Address
- Clear-AnsiSequence
- ConvertTo-AnsiSequence
- ConvertTo-AnsiString
- ConvertTo-DifferenceString
- ConvertTo-RelativePath
- Disable-CursorShortcutCode
- Get-ClassAst
- Get-ClassResourceAst
- Get-GitBranchCommit
- Get-GitLocalBranchName
- Get-GitRemote
- Get-GitRemoteBranch
- Get-GitTag
- Get-LinkLayerAddress
- Get-ModuleByVersion
- Get-ModuleFileSha
- Get-ModuleVersion
- Get-NumericalSequence
- Get-PSReadLineHistory
- Get-TextOffset
- Install-ModulePatch
- Invoke-Git
- Invoke-PesterJob
- New-GitTag
- New-SamplerGitHubReleaseTag
- Out-Difference
- Pop-VMLatestSnapshot
- Push-GitTag
- Receive-GitBranch
- Remove-GitTag
- Remove-History
- Remove-PSHistory
- Remove-PSReadLineHistory
- Rename-GitLocalBranch
- Rename-GitRemote
- Request-GitTag
- Resolve-DnsName
- Resume-GitRebase
- Send-WakeOnLan
- Split-StringAtIndex
- Start-GitRebase
- Stop-GitRebase
- Switch-GitLocalBranch
- Test-FileHash
- Test-GitLocalChanges
- Test-GitRemote
- Test-GitRemoteBranch
- Test-IPv4Address
- Update-GitLocalBranch
- Update-RemoteTrackingBranch