PowerShell Snippets: Get Numeric Value from String

PowerShellThis post is part of the series on PowerShell Snippets.

In the previous post, I showed how a single element could be retrieved from a GitHub release by executing curl and selecting the required element.

I quickly discovered that the element retrieved in this was contained some additional characters and I needed only the numeric ones. The PowerShell below will extract the numeric elements of the $id variable and return them in the $releaseID variable:

$releaseID = $id -replace "[^0-9]" , ''

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *