Provided by: librgxg-dev_0.1-1_amd64

**NAME**

rgxg_number_range, rgxg_number_greaterequal - create regex that matches integers in the given range

**SYNOPSIS**

#include<rgxg/number.h>intrgxg_number_range(longlongfirst,longlonglast,intbase,size_tmin_length,char*regex,rgxg_options_toptions);intrgxg_number_greaterequal(longlongnumber,intbase,size_tmin_length,char*regex,rgxg_options_toptions);

**DESCRIPTION**

rgxg_number_range() generates the (extended) regular expression that matches integers in the range betweenfirstandlast.rgxg_number_greaterequal() generates the (extended) regular expression that matches integers greater than or equal tonumber. The base of the matched integers is specified bybase, which must be between 2 and 32 inclusive. Note that for bases greater than 16 the "extended hex" alphabet is used (referenced as 'base32hex' inRFC4648). IfRGXG_LEADINGZEROorRGXG_VARLEADINGZEROis set, thenmin_lengthspecifies the minimum length of the matched integers (otherwise the argument is ignored). For instance the number 5 withmin_lengthset to 3 and options set toRGXG_LEADINGZEROis matched as '005'. By default the number of leading zeros depends on the length of thelastnumber. Ifmin_lengthis lesser than or equal to the number of digits oflast, the value has no effect. The generated regular expression is written to the character stringregex, including the terminating null byte ('\0'), unlessRGXG_NONULLBYTEis set. Ifregexis NULL the return value is the number of characters (excluding the terminating null byte) that would have been written in caseregexhas been initialized. Note that the functions assume an arbitrarily longregexstring, callers mustensurethat the given string is large enough to not overflow the actual space.optionsis either zero, or the bitwise-orof one or more of the following macros:RGXG_NOUPPERCASEThe generated regular expression only matches lower case letters forbasevalues greater than 10. The default is to match both lower and upper case letters.RGXG_NOLOWERCASEThe generated regular expression only matches upper case letters forbasevalues greater than 10. The default is to match both lower and upper case letters.RGXG_NOOUTERPARENSOmit the outer parenthesis, if any, of the regular expression.RGXG_LEADINGZEROThe 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 themin_lengthargument (see above). By default no leading zeros are matched.RGXG_VARLEADINGZEROThe 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 themin_lengthargument (see above). By default no leading zeros are matched.RGXG_NONULLBYTEDo not add the terminating null byte ('\0') to theregexstring. Note thatRGXG_NOUPPERCASEandRGXG_NOLOWERCASEas well asRGXG_LEADINGZEROandRGXG_VARLEADINGZEROare mutual exclusive options.

**RETURN** **VALUE**

Upon successful return, these functions return the number of characters (excluding the terminating null byte) written toregex. If an error occurs, a (negative) error code is returned (seeERRORSsection).

**ERRORS**

The following errors can be returned:RGXG_ERROR_RANGE(rgxg_number_range() only) Invalid range (e.g.firstnumber is greater thanlastnumber).RGXG_ERROR_BASEThe base is lesser than 2 or greater than 32.RGXG_ERROR_NEGARGAt least one argument is negative.RGXG_ERROR_ARG2BIG(rgxg_number_greaterequal() only) The value ofnumberis too large.RGXG_ERROR_MUTEXOPTIONSTwo mutual exclusive options were specified.

**AVAILABILITY**

These functions are available since rgxg 0.1.

**SEE** **ALSO**

regex(7),rgxg_net_cidr_ipv4(3),rgxg_net_cidr_ipv6(3),rgxg_net_cidr_string(3).

**AUTHOR**

Hannes von Haugwitz <hannes@vonhaugwitz.com>