philiprehberger-regex_lib 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71785476779a6373cf4d64efa8b389f7e25767df8f902a5a6190f908da397256
4
- data.tar.gz: 9e53e782bb0e921adb28d0111cee7c7410ba66b3cc3023132c67f3d49837c9d3
3
+ metadata.gz: c679a94104bc2a1af5329e43737060db3a8a9dd9eb8a5672f30ad095d5b6aaf4
4
+ data.tar.gz: c82822e809f812e605d338a689ea344d7fd82abae6128824347a2271141acc39
5
5
  SHA512:
6
- metadata.gz: fee7e88e625b22b3416c30347425b7ed4f4e263f14588f59f4086594ceba1172a10b24f43f81ecd2e73690a304023d677fdd4461a9e0070d25da285bd71c0fe6
7
- data.tar.gz: f51ed81c43284b661a7fd118d407dcd4d1bb3c3082e272756699110c1670b94429badc064b0359fc5adf6380c21a8559c1eb3f0984995855c60387edfbafc39f
6
+ metadata.gz: 2339d7485948605cb49e7e5a2a52800ea33724c2660b4ac4a9fa9664153bb27b03072c41ed68fdf0b07f6f26e2e2007058ee9a861bf1b3172cfd010726084c57
7
+ data.tar.gz: 9773d2ecd44db34f84a8ebe9d2e4b893c38191773ce7f0cfe604cad1048a122eb5ace7f26e099770bdcd9cc240f2d7cd7c6fa955c0ffcc4eb59a71435185c2bd
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.7.0] - 2026-06-14
11
+
12
+ ### Added
13
+ - `RegexLib.any_match?(pattern_name, *strings)` — true if any of the supplied strings matches the named pattern. Convenience wrapper for the common `any? { |s| match?(name, s) }` pattern in form-validation use cases.
14
+
10
15
  ## [0.6.0] - 2026-04-22
11
16
 
12
17
  ### Added
data/README.md CHANGED
@@ -4,6 +4,8 @@
4
4
  [![Gem Version](https://badge.fury.io/rb/philiprehberger-regex_lib.svg)](https://rubygems.org/gems/philiprehberger-regex_lib)
5
5
  [![Last updated](https://img.shields.io/github/last-commit/philiprehberger/rb-regex-lib)](https://github.com/philiprehberger/rb-regex-lib/commits/main)
6
6
 
7
+ ![philiprehberger-regex_lib](https://raw.githubusercontent.com/philiprehberger/rb-regex-lib/main/package-card.webp)
8
+
7
9
  Pre-built regex patterns for emails, URLs, IPs, dates, and more
8
10
 
9
11
  ## Requirements
@@ -195,11 +197,21 @@ Philiprehberger::RegexLib.scan(text).select { |r| [:ssn, :credit_card].include?(
195
197
  | `CRON_EXPRESSION` | Cron expression (minute hour day month weekday) |
196
198
  | `CIDR` | CIDR notation (IPv4/prefix length) |
197
199
 
200
+ ### Any-of Matching
201
+
202
+ ```ruby
203
+ require "philiprehberger/regex_lib"
204
+
205
+ inputs = ['not-an-email', 'foo@bar.com', 'also-not']
206
+ Philiprehberger::RegexLib.any_match?(:email, *inputs) # => true
207
+ ```
208
+
198
209
  ## API
199
210
 
200
211
  | Method | Description |
201
212
  |--------|-------------|
202
213
  | `RegexLib.match?(pattern_name, string)` | Test string against a named pattern, returns `true`/`false` |
214
+ | `.any_match?(name, *strings)` | True if any of the strings matches the named pattern |
203
215
  | `RegexLib.extract(pattern_name, string)` | Extract named captures as a `Hash`, full match as `String`, or `nil` |
204
216
  | `RegexLib.extract_all(pattern_name, string)` | Find all matches in the string, returns `Array<String>` |
205
217
  | `RegexLib.count(pattern_name, string)` | Count non-overlapping matches in the string, returns `Integer` |
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Philiprehberger
4
4
  module RegexLib
5
- VERSION = '0.6.0'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
@@ -35,6 +35,20 @@ module Philiprehberger
35
35
  pattern.match?(string)
36
36
  end
37
37
 
38
+ # True when at least one of the given strings matches the named pattern.
39
+ #
40
+ # Equivalent to `strings.any? { |s| match?(pattern_name, s) }` but avoids
41
+ # the closure allocation on call sites that just need a yes/no answer.
42
+ #
43
+ # @param pattern_name [Symbol] the pattern name (e.g. :email, :url, :ipv4)
44
+ # @param strings [Array<String>] the strings to test
45
+ # @return [Boolean] true if any string matches the pattern
46
+ # @raise [Error] if the pattern name is not recognized
47
+ def self.any_match?(pattern_name, *strings)
48
+ pattern = resolve_pattern!(pattern_name)
49
+ strings.any? { |s| pattern.match?(s) }
50
+ end
51
+
38
52
  # Extract named captures from a string using a named pattern.
39
53
  #
40
54
  # @param pattern_name [Symbol] the pattern name (e.g. :date_iso, :semantic_version)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: philiprehberger-regex_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philip Rehberger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-22 00:00:00.000000000 Z
11
+ date: 2026-06-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A library of tested, documented regex patterns for common data formats.
14
14
  Includes named captures, validation helpers, and extraction methods.