Regex find hotfixes in a text or filename

Welcome Forums General PowerShell Q&A Regex find hotfixes in a text or filename

Viewing 2 reply threads
  • Author
    Posts
    • #52448
      Participant
      Topics: 21
      Replies: 43
      Points: 2
      Rank: Member

      Hi Using PowerSHell 5

      I'm trying to pick out 'kb3114938' -type hotfixes from filenames (soifjokb3114938j44idsi) and texts. So the "kb" stays the same while the 7 numbers change depending on what hotfix im searching for. So basically i want to pick up every 'kb'+ 7 following numbers.
      Any Regual Expression experts out there?

      brgs

      Bjørn

    • #52450
      Moderator
      Topics: 2
      Replies: 525
      Points: 24
      Team Member
      Rank: Member

      Hi Bjørn,

      Please check if below works for you.

      $text = 'soifjokb3114938j44idsi'
      if ($text -match 'kb\d{7}') {
          $kbNumber = $Matches[0]
          $kbNumber
      }
      
    • #52453
      Participant
      Topics: 21
      Replies: 43
      Points: 2
      Rank: Member

      Hi Daniel

      Wow great, works nicely!
      Thank you very much!

      Brgs

      Bjørn

Viewing 2 reply threads
  • The topic ‘Regex find hotfixes in a text or filename’ is closed to new replies.