Vulcan - 1 year ago 84

PHP Question

Consider the following regular expression, where

`X`

`X{n}|X{m}`

This regex would test for

`X`

`n`

`m`

Is there a regex quantifier that can test for an occurrence

`X`

`n`

`m`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

There is no single quantifier that means "exactly m or n times". The way you are doing it is fine.

An alternative is:

```
X{m}(X{k})?
```

where `m < n`

and `k`

is the value of `n-m`

.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**