Get character from string

This topic contains 3 replies, has 3 voices, and was last updated by  Tony Antony 11 months ago.

  • Author
    Posts
  • #62050

    Tony Antony
    Participant

    I have a string [MembersOf-1]

    How would I get 1? I know you can use trim("[MembersOf-"), but then it will leave me with 1]

    I know i can use trim or replace, but how would I take care of it all once.

    Thanks?

    Tony

  • #62052

    random commandline
    Participant
    $string = '[MembersOf-1]'
    $string -match '-(\d+)' | Out-Null ; $Matches[1]
    
  • #62053

    Paul Frankovich
    Participant
    $String -Replace '\D+'
  • #62055

    Tony Antony
    Participant

    Thank you all

You must be logged in to reply to this topic.