Please feel free to provide feedback or file bugs here.

TrimStart() method trimming more than specified

Attempting to compare two strings. When constructing one of the strings, the TrimStart method is trimming more of the string than it should. Example:

(Get-Content -Path 'C:\Program Files\SplunkUniversalForwarder\etc\system\local\server.conf' | Select-String -Pattern 'serverName').ToString().TrimStart('serverName = ')

returns

rver1.domain.company.com

expected output is

server1.domain.company.com

I expanded the TrimStart method like so:

(Get-Content -Path 'C:\Program Files\SplunkUniversalForwarder\etc\system\local\server.conf' | Select-String -Pattern 'serverName').ToString().TrimStart('serverName').TrimStart(' ').TrimStart('=').TrimStart(' ')

and get the same erroneous output. The problem appears to be with trimming the last space character.

1 vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Brett Anspach shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    1 comment

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base