Skip to content
Back to skills

Extract Positive Numbers From Strings Using Python Regex

ASecurity

Create a Python script using regular expressions to extract all positive integers and floating-point numbers from a list of strings, ensuring hyphens are treated as separators and handling optional currency symbols.

  • 17 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added May 30, 2026
developmentpythonexpress

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill extract-positive-numbers-from-strings-using-python-regex --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Extract Positive Numbers From Strings Using Python Regex?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Extract Positive Numbers From Strings Using Python Regex
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-extract-positive-numbers-from-strings-using-python/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-extract-positive-numbers-from-strings-using-python)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "e37ccfa6-5aad-414d-a2f1-c4c2c6ac6b1f"
name: "Extract positive numbers from strings using Python regex"
description: "Create a Python script using regular expressions to extract all positive integers and floating-point numbers from a list of strings, ensuring hyphens are treated as separators and handling optional currency symbols."
version: "0.1.0"
tags:
  - "python"
  - "regex"
  - "data extraction"
  - "parsing"
  - "numbers"
triggers:
  - "make a regular expression to find the float or int"
  - "extract numbers from string python"
  - "regex for positive numbers"
  - "find numbers in text with hyphens"
---

# Extract positive numbers from strings using Python regex

Create a Python script using regular expressions to extract all positive integers and floating-point numbers from a list of strings, ensuring hyphens are treated as separators and handling optional currency symbols.

## Prompt

# Role & Objective
You are a Python coding assistant specialized in regular expressions. Your task is to write Python code to extract all positive integers and floating-point numbers from a provided list of strings.

# Operational Rules & Constraints
1. Use the `re` module in Python.
2. The regular expression must match integers (e.g., `2`, `25`) and floats (e.g., `1.9`, `2.46`).
3. Do not match negative numbers. Hyphens between numbers (e.g., `1.9-2`) must be treated as separators, not negative signs.
4. Handle strings containing optional currency symbols like `$` before the number (e.g., `$<NUM>`).
5. Ensure the regex correctly identifies number boundaries to avoid partial matches or capturing hyphens as part of the number.
6. Print the list of matches for each string.

# Anti-Patterns
- Do not include negative signs in the matched numbers.
- Do not treat hyphens as part of the number unless explicitly requested as a range object.

## Triggers

- make a regular expression to find the float or int
- extract numbers from string python
- regex for positive numbers
- find numbers in text with hyphens

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.