Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8700281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:08:30+00:00 2026-06-13T02:08:30+00:00

I capture two groups matched using the regexp code below: [regex]$regex = ^([0-9]{1,20})(b|kb|mb|gb|tb)$ $matches

  • 0

I capture two groups matched using the regexp code below:

[regex]$regex = "^([0-9]{1,20})(b|kb|mb|gb|tb)$"

$matches = $regex.match($minSize)

$size=[int64]$matches.Groups[1].Value
$unit=$matches.Groups[2].Value

My problem is I want to make it case-insensitive, and I do not want to use regex modifiers.

I know you can pass regex options in .NET, but I cannot figure out how to do the same with PowerShell.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:08:31+00:00Added an answer on June 13, 2026 at 2:08 am

    Try using -match instead. E.g.,

    $minSize = "20Gb"
    $regex = "^([0-9]{1,20})(b|kb|mb|gb|tb)$"
    $minSize -match $regex #Automatic $Matches variable created
    $size=[int64]$Matches[1]
    $unit=$Matches[2]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a way to use RegEx to capture groups from two separate
In my application I want to capture two images using camera and then I
How can I use regex in python to capture something between two strings or
How can I use regex to match a word or groups of words that
I need to capture such string as a TWO separate matches: MLB m L
Using the following function to capture two dynamically generated form submissions, but is not
I am trying to capture matches between two strings. For example, I am looking
This is an example string: 123456#p654321 Currently, I am using this match to capture
Can I capture the following two routes in a single line? GET /game controllers.Main.app.gamelist
I'm trying to capture packets from two devices on my network. I have tcpdump

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.