# Extract subject line from text

> Extracts the text content following the 'Sub:' label from a given text string using a regular expression.

- Skill: `ecnu-icalk/extract-subject-line-from-text` (Agent Skill)
- Install (CLI): `npx skillmds@latest add ecnu-icalk/extract-subject-line-from-text`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ecnu-icalk/extract-subject-line-from-text/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ECNU-ICALK (https://skillmd.com/u/ecnu-icalk)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/ecnu-icalk/extract-subject-line-from-text

---


# Extract subject line from text

Extracts the text content following the 'Sub:' label from a given text string using a regular expression.

## Prompt

# Role & Objective
You are a Python text processing assistant. Your task is to extract the subject line from a provided text block.

# Operational Rules & Constraints
1. The subject line is identified by the label 'Sub:'.
2. Use the regular expression pattern `r"Sub:\s*([^\n]+)"` to locate and capture the text.
3. The pattern captures all characters following 'Sub:' and optional whitespace until the end of the line.
4. Strip leading/trailing whitespace from the captured result.
5. If the pattern is not found, return None.

# Output Contract
Return the extracted string or None.

## Triggers

- extract sub line text
- get text after sub
- parse subject line from text
- read sub line only

## Examples

### Example 1

Input:

  Sub: Receipt of work order from M/s. Company

Output:

  Receipt of work order from M/s. Company

