PHPackages                             antevenio/stream-regex-iterator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. antevenio/stream-regex-iterator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

antevenio/stream-regex-iterator
===============================

PHP iterator of regex matches over streams

0.0.4(7y ago)115.1k↓66.8%MITPHPPHP &gt;=5.6

Since May 16Pushed 7y ago1 watchersCompare

[ Source](https://github.com/pinfake/stream-regex-iterator)[ Packagist](https://packagist.org/packages/antevenio/stream-regex-iterator)[ Docs](https://github.com/pinfake/stream-regex-iterator)[ RSS](/packages/antevenio-stream-regex-iterator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (3)Used By (0)

stream-regex-iterator
=====================

[](#stream-regex-iterator)

Find regular expresion matches on seekable text streams and return them inside an iterator.

Description
-----------

[](#description)

This iterator comes as a solution to having to run complex multi line regular expressions on big files without exhausting memory.

The iterator will read chunks of data from the stream and run `preg_match_all()`on each one of them.

The iterator will read chunks of data in a way that it ensures no possible matches are lost through chunks, i.e. possible matches existing amidst chunk split points.

The iterator will return matches as `preg_match_all()` would do when using the `PREG_SET_ORDER | PREG_OFFSET_CAPTURE` flags.

Limitations
-----------

[](#limitations)

The specified stream must be fully seekable (back and forward).

The specified buffer size must be able to store the longest possible full match of the regexp.

The iterator will require approximately twice the specified buffer size memory.

Requirements
------------

[](#requirements)

The following versions of PHP are supported.

- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- PHP 7.3

Installation:
-------------

[](#installation)

```
composer require antevenio/stream-regex-iterator

```

Usage
-----

[](#usage)

```
$inputString = "line1\nline2\nline3\nline4\nline5\nstart\nline6\nline7\nend";

$stream = fopen("data://text/plain," . $inputString, "r");

$matches = new Antevenio\StreamRegexIterator\Iterator(
    "/^start.*?end$/sm",
    $stream,
    32
);

foreach ($matches as $match) {
    print_r($match);
}
```

Would output:

```
Array
(
    [0] => Array
        (
            [0] => start
line6
line7
end
            [1] => 30
        )

)

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

2606d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3945156?v=4)[Iván Mota](/maintainers/pinfake)[@pinfake](https://github.com/pinfake)

---

Top Contributors

[![pinfake](https://avatars.githubusercontent.com/u/3945156?v=4)](https://github.com/pinfake "pinfake (1 commits)")

---

Tags

bigexpressionfileiteratormemoryphpregularsafestreamstreamiteratorregexregular expression

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antevenio-stream-regex-iterator/health.svg)

```
[![Health](https://phpackages.com/badges/antevenio-stream-regex-iterator/health.svg)](https://phpackages.com/packages/antevenio-stream-regex-iterator)
```

###  Alternatives

[composer/pcre

PCRE wrapping library that offers type-safe preg\_\* replacements.

707347.9M60](/packages/composer-pcre)[react/stream

Event-driven readable and writable streams for non-blocking I/O in ReactPHP

691146.0M211](/packages/react-stream)[spatie/regex

A sane interface for php's built in preg\_\* functions

1.1k19.8M70](/packages/spatie-regex)[nikic/iter

Iteration primitives using generators

1.1k6.4M55](/packages/nikic-iter)[loophp/collection

A (memory) friendly, easy, lazy and modular collection class.

745762.4k16](/packages/loophp-collection)[gherkins/regexpbuilderphp

PHP port of thebinarysearchtree/regexpbuilderjs

1.3k189.0k1](/packages/gherkins-regexpbuilderphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
