Using regex for text extraction
Regex Text Extraction Guide
This guide covers the regex patterns supported by our platform for text extraction. Our focus is on helping you extract specific text patterns from strings rather than validation or assertion operations.
Need help creating a regex pattern? You can ask ChatGPT to generate one for you based on your requirements, then use it directly in our platform.
Examples
Example 1: Extracting amount
Pattern: ₹\s*([0-9]+)
Input: ₹100
Output: 100
Example 2: Extracting Phone Numbers
Pattern: (\d{3}[-.\s]?\d{3}[-.\s]?\d{4})
Input: Call us at 555-123-4567 or 555.987.6543 for more information.
Output: 555-123-4567
Example 3: Extracting URLs
Pattern: (https?://[^\s]+)
Input: Visit our website at https://example.com or http://demo.example.org for more details.
Output: https://example.com
Example 4: Named Capture Groups
Pattern: (?<username>[a-zA-Z0-9_]+):(?<message>.+)
Input: john_doe: Hello world! alice_smith: How are you?
Output: username: john_doe, message: Hello world!
Example 5: Extracting Dates
Pattern: (\d{1,2}/\d{1,2}/\d{2,4})
Input: The meeting is scheduled for 10/15/2023 and the deadline is 12/31/2023.
Output: 10/15/2023
Example 6: Extracting Product Codes
Pattern: ([A-Z]{2}-\d{4})
Input: Please reorder products AB-1234 and CD-5678 before next month.
Output: AB-1234
Example 7: Extracting Hashtags
Pattern: (#\w+)
Input: Check out our new product launch #NewRelease #Innovation #Tech
Output: #NewRelease
Example 8: Extracting Time
Pattern: (\d{1,2}:\d{2}(?::\d{2})?\s*(?:AM|PM)?)
Input: The meeting starts at 9:30 AM and ends at 11:45 AM.
Output: 9:30 AM
Example 9: Extracting Names
Pattern: (Mr\.|Ms\.|Mrs\.|Dr\.)\s([A-Z][a-z]+)
Input: Dr. Smith and Mrs. Johnson will attend the conference.
Output: Dr. Smith
Example 10: Extracting IP Addresses
Pattern: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
Input: The server IP addresses are 192.168.1.1 and 10.0.0.1
Output: 192.168.1.1
Features Not Covered
Our platform focuses on text extraction and does not support:
Lookahead/lookbehind assertions
Atomic grouping
Conditional patterns
Advanced backtracking controls
Last updated