Other Alias

rgxg_number_greaterequal## SYNOPSIS

**#include <rgxg/number.h>****int rgxg_number_range (long long ***first***, long long ***last***, int ***base***,**

**size_t ***min_length***, char ****regex***, rgxg_options_t ***options***);****int rgxg_number_greaterequal (long long ***number***, int ***base***,**

**size_t ***min_length***, char ****regex***, rgxg_options_t ***options***);**

## DESCRIPTION

**rgxg_number_range**() generates the (extended) regular expression that matches integers in the range between

*first*and

*last*.

**rgxg_number_greaterequal**()
generates the (extended) regular expression that matches integers greater than or equal to
*number*.

The base of the matched integers is specified by
*base*,
which must be between 2 and 32 inclusive. Note that for bases greater than 16 the "extended hex" alphabet is used (referenced as 'base32hex' in
**RFC 4648**).

If
**RGXG_LEADINGZERO** or **RGXG_VARLEADINGZERO**
is set, then
*min_length*
specifies the minimum length of the matched integers (otherwise the argument is ignored). For instance the number 5 with
*min_length*
set to 3 and
options set to
**RGXG_LEADINGZERO**
is matched as '005'. By default the number of leading zeros depends on the length of the
*last*
number. If
*min_length*
is lesser than or equal to the number of digits of
*last*,
the value has no effect.

The generated regular expression is written to the character string
*regex*,
including the terminating null byte ('\0'), unless
**RGXG_NONULLBYTE**
is set. If
*regex*
is NULL the return value is the number of characters (excluding the terminating null byte) that would have been written in case
*regex*
has been initialized. Note that the functions assume an arbitrarily long
*regex*
string, callers must
**ensure**
that the given string is large enough to not overflow the actual space.

*options*
is either zero, or the
bitwise-**or**
of one or more of the following macros:

**RGXG_NOUPPERCASE**-
The generated regular expression only matches lower case letters for
*base*values greater than 10. The default is to match both lower and upper case letters. **RGXG_NOLOWERCASE**-
The generated regular expression only matches upper case letters for
*base*values greater than 10. The default is to match both lower and upper case letters. **RGXG_NOOUTERPARENS**-
Omit the outer parenthesis, if any, of the regular expression.
**RGXG_LEADINGZERO**-
The generated regular expression only matches integers with leading zeros (e.g. the integer 5 is only matched as '005'). The number of leading zeros is influenced by the
*min_length*argument (see above). By default no leading zeros are matched. **RGXG_VARLEADINGZERO**-
The generated regular expression matches integers with a variable number of leading zeros (e.g. the number 5 is matched as '5', '05' and '005'). The maximum number of leading zeros is influenced by the
*min_length*argument (see above). By default no leading zeros are matched. **RGXG_NONULLBYTE**-
Do not add the terminating null byte ('\0') to the
*regex*string.

Note that
**RGXG_NOUPPERCASE** and **RGXG_NOLOWERCASE**
as well as
**RGXG_LEADINGZERO** and **RGXG_VARLEADINGZERO**
are mutual exclusive options.

## RETURN VALUE

Upon successful return, these functions return the number of characters (excluding the terminating null byte) written to
*regex*.

If an error occurs, a (negative) error code is returned (see
**ERRORS**
section).

## ERRORS

The following errors can be returned:**RGXG_ERROR_RANGE**(**rgxg_number_range**() only)-
Invalid range (e.g.
*first*number is greater than*last*number). **RGXG_ERROR_BASE**- The base is lesser than 2 or greater than 32.
**RGXG_ERROR_NEGARG**- At least one argument is negative.
**RGXG_ERROR_ARG2BIG**(**rgxg_number_greaterequal**() only)-
The value of
*number*is too large. **RGXG_ERROR_MUTEXOPTIONS**-
Two mutual exclusive options were specified.

## AVAILABILITY

These functions are available since rgxg 0.1.