Get character from string

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by Profile photo of Tony Antony Tony Antony 4 months, 1 week ago.

  • Author
    Posts
  • #62050
    Profile photo of Tony Antony
    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
    Profile photo of random commandline
    random commandline
    Participant
    $string = '[MembersOf-1]'
    $string -match '-(\d+)' | Out-Null ; $Matches[1]
    
  • #62053
    Profile photo of Paul Frankovich
    Paul Frankovich
    Participant
    $String -Replace '\D+'
  • #62055
    Profile photo of Tony Antony
    Tony Antony
    Participant

    Thank you all

You must be logged in to reply to this topic.