PHPackages                             sedhossein/pregex - 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. sedhossein/pregex

ActiveLibrary

sedhossein/pregex
=================

Recommended regex's For Persian/Farsi(fa) Language

v1.2.0(5y ago)35122[1 issues](https://github.com/sedhossein/pregex/issues)[1 PRs](https://github.com/sedhossein/pregex/pulls)MITPHPPHP ^7.2CI failing

Since Aug 23Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/sedhossein/pregex)[ Packagist](https://packagist.org/packages/sedhossein/pregex)[ RSS](/packages/sedhossein-pregex/feed)WikiDiscussions master Synced today

READMEChangelog (5)Dependencies (1)Versions (7)Used By (0)

Pregex: Claim any Persian|Iranian|Farsi|Arabic Regular Expressions that you need
--------------------------------------------------------------------------------

[](#pregex-claim-any-persianiranianfarsiarabic-regular-expressions-that-you-need)

[![Build Status](https://camo.githubusercontent.com/e450f0d9538786076885d7dddbe34970ad31816e39c73ac6eaff9da8b42c455b/68747470733a2f2f7472617669732d63692e6f72672f736564686f737365696e2f7072656765782e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/sedhossein/pregex)[![Coverage Status](https://camo.githubusercontent.com/3569c10d34b4510a6d6b3939dee6c893637eb370569bd495e000a9b62b7325f3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f736564686f737365696e2f7072656765782f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/sedhossein/pregex?branch=master)[![Version](https://camo.githubusercontent.com/957b8da9e938105ba9e831e68023176d0fc6b7fd016fd34418a46e57a5fe88e7/68747470733a2f2f706f7365722e707567782e6f72672f736564686f737365696e2f7072656765782f76657273696f6e)](https://packagist.org/packages/sedhossein/pregex)[![Total Downloads](https://camo.githubusercontent.com/be434943a8d4bd814a0417bb18e7ebe88d59f9e11ddf63ea1b13080cfb27584a/68747470733a2f2f706f7365722e707567782e6f72672f736564686f737365696e2f7072656765782f646f776e6c6f616473)](https://packagist.org/packages/sedhossein/pregex)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/ad7421acf44a7ded73379534a7862fb96581ba173787c0f109f08dad122602dd/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f736564686f737365696e2f7072656765782f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/sedhossein/pregex/?branch=master)[![License](https://camo.githubusercontent.com/755671dde4af9eba69c8a62c6e2d10ac124ac012c2c9539407a3c8280d4e1acf/68747470733a2f2f706f7365722e707567782e6f72672f736564686f737365696e2f7072656765782f6c6963656e7365)](//packagist.org/packages/sedhossein/pregex)

Quick Access
------------

[](#quick-access)

- [Introduction](#introduction)
- [Requirements](#requirements)
- [How to use](#how-to-use)
    - [List of methods](#list-of-methods)
- [Installation](#how-to-install)
- [Run Tests](#run-tests)
- [TODO list](#todo-list)
- [License](#license)

### Introduction

[](#introduction)

If you having a Persian/Iranian project and need to validate your inputs this light library can help you. Pregex try to make a complete collection of Persian/Iranian validations to make it easy for you. Please kindly feeling free to get in touch with me for any idea you have, or open issue/PR to any bug reporting/fixing.

### Requirements

[](#requirements)

- composer
- PHP 7.2 &gt;=

### How to use

[](#how-to-use)

Pregex prepared the bellow methods list to give you all you need for your validations.

```
use Sedhossein\Pregex\Pregex;

$false = (new Pregex)->IsPersianOrArabicNumber("123456"); // False, cause `123456` are english numbers
$true = (new Pregex)->IsPersianOrArabicNumber("۱۲۳۴۵۶");  // True, cause `123456` are persian numbers
```

You can see some more examples in `./examples/index.php`

#### list of methods

[](#list-of-methods)

```
function IsPersianNumber(string $number): bool;
```

`IsPersianNumber` just validate persian alphabets(not arabic)

---

```
function IsArabicNumber(string $number): bool;
```

`IsArabicNumber` just validate arabic alphabets(not persian)

---

```
function IsPersianOrArabicNumber(string $number): bool;
```

`IsPersianOrArabicNumber` validate both Arabic and Persian alphabets. It can be useful when you need just Persian texts and user keyboards maybe having different languages(iPhone keyboards, android keyboards or non-standard keyboards)

---

```
function IsEmail(string $email): bool;
```

`IsEmail` validate emails! Just for getting Pregex more complete for our mission ;))

---

```
function IsCellphone(string $number): bool;
```

`IsCellphone` validate persian cellphone numbers. Valid inputs can begin with `+98{..}`, `98{..}`, `09{..}`, `9{..}`

---

```
function IsIban(string $value): bool;
```

`IsIban` or also `Sheba` or `International Bank Account Number (IBAN).` validate Iranian bank Ibans

---

```
function IsNationalCode(string $value): bool;
```

`IsNationalCode` or also `Melli Code!` validate Iranian national codes

---

```
function IsCardNumber(string $value): bool;
```

`IsCardNumber` validate Iranian bank card numbers

---

```
function IsPostalCode(string $value): bool;
```

`IsPostalCode` validate Iranian postal code numbers

---

```
function IsPersianText(string $value): bool;
```

`IsPersianText` validate Iranian and some Arabic alphabets with some held in common writing signs.

### How to install

[](#how-to-install)

Install [Composer](https://getcomposer.org) and run following command in your project's root directory:

```
composer require sedhossein/pregex
```

### Run Tests

[](#run-tests)

After installing [Composer](https://getcomposer.org), Clone Pregex Repo and then go to project path(`cd pregex`). Now enter:

```
composer install
```

Now you fetch all of package dependencies, and you can run bellow command to run tests:

```
./vendor/phpunit/phpunit/phpunit  --coverage-html ./build/tests/coverage.html
```

So after running above command you can see coverage report on `./build/tests/coverage.html`

### TODO list:

[](#todo-list)

- Comparing with other libraries to add more features

### license

[](#license)

Pregex is initially created by [Sedhossein](https://sedhossein.dev) and released under the [MIT License](http://opensource.org/licenses/mit-license.php).

###  Health Score

32

—

LowBetter than 74% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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 ~4 days

Total

4

Last Release

2027d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96859462096a8e3c54388798eb60fbd5e4be7000155b80566700ae0a80947d4b?d=identicon)[sedhossein](/maintainers/sedhossein)

---

Top Contributors

[![sedhossein](https://avatars.githubusercontent.com/u/26527879?v=4)](https://github.com/sedhossein "sedhossein (38 commits)")

---

Tags

laravelpersianphpphp7regexregexesvalidation-libraryphplaravelregexPersian RegexPregexSedhossein

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sedhossein-pregex/health.svg)

```
[![Health](https://phpackages.com/badges/sedhossein-pregex/health.svg)](https://phpackages.com/packages/sedhossein-pregex)
```

###  Alternatives

[tomatophp/filament-users

Manage your users with a highly customizable user resource for FilamentPHP with integration of filament-shield and filament-impersonate

8995.4k7](/packages/tomatophp-filament-users)[octw/aramex

A Library to integrate with Aramex APIs

2924.7k](/packages/octw-aramex)

PHPackages © 2026

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