How to ignore first open barkets

Welcome Forums General PowerShell Q&A How to ignore first open barkets

Viewing 1 reply thread
  • Author
    Posts
    • #276798
      Participant
      Topics: 15
      Replies: 20
      Points: 158
      Rank: Participant

      Hi, I have following line of code which works fine but when a string which has two () it only picking the first one

      What I want to do is if more then 1 is found then only send the last one.

      This is the name of the movie on IMDB: Home (II) (2015)

      $Released = (($Match -split “ \(“)[1] -split “\)”)[0]

      I’m using following code to get the movie detials.

      https://pastebin.com/raw/5k3ad8TM

    • #276807
      Participant
      Topics: 4
      Replies: 427
      Points: 756
      Helping Hand
      Rank: Major Contributor

      If it’s always at the end of string, probably best to use $ to specify you want to match the end of the string.

      $film = ‘Home (II) (2015)’
      [regex]::Match($film,”\(\d+\)$”).Value

      • This reply was modified 1 month, 2 weeks ago by grokkit.
      • This reply was modified 1 month, 2 weeks ago by grokkit.
      • This reply was modified 1 month, 2 weeks ago by grokkit.
      • This reply was modified 1 month, 2 weeks ago by grokkit.
      • This reply was modified 1 month, 2 weeks ago by grokkit.
Viewing 1 reply thread
  • You must be logged in to reply to this topic.