module
CliGen::Regex
Defined in:
cligen/regex.crConstant Summary
-
DATE =
/(?<date>(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2}))/ -
EPOCH =
/@(?<epoch>[0-9]+)/ -
FLAG_MULTIPLE_SHORT =
/^-[a-zA-Z0-9]+$/ -
FLAG_REGEX =
/^(-[a-zA-Z]|--[a-zA-Z-_0-9]+)$/ -
FLAG_WITH_ARG =
/^(?<flag>(-[a-zA-Z]|--[a-zA-Z-_]+))="?(?<arg>\S+?)"?$/ -
FLOAT =
/^[-+]?[[:digit:]]+(\.[[:digit:]]+)?$/ -
INPUT_DATE_EPOCH =
/^#{EPOCH}(\s+#{TIMEZONE})?$/ -
INPUT_DATE_FULL =
/^#{DATE}\s+#{TIME}(\s+#{TIMEZONE})?$/ -
Date/time matchers - fully anchored so a partial match can't slip through.
-
INPUT_DATE_SIMPLE =
/^#{DATE}(\s+#{TIMEZONE})?$/ -
INPUT_RELATIVE_OPERATIONS =
/^(?<operations>(#{RELATIVE}\s*)+)(\s+#{TIMEZONE})?$/ -
INT =
/^[-+]?[[:digit:]]+$/ -
RELATIVE =
/[+-][0-9]+\s+(seconds?|minutes?|hours?|days?|weeks?|months?|years?)/ -
RELATIVE_OPERATION =
/(?<sign>[+-])(?<quantity>[0-9]+)\s+(?<unit>seconds?|minutes?|hours?|days?|weeks?|months?|years?)/ -
Relative Operation matcher - For use with CliGen::Timeparse::RelativeOperation
-
TIME =
/(?<time>(?<hour>[0-9]{2}):(?<minute>[0-9]{2}):(?<second>[0-9]{2}))/ -
TIMEZONE =
/(?<timezone>(?<offset_sign>[-+])(?<offset_hour>[01][0-9]|2[0-3])(?<offset_minute>[0-5][0-9]))/ -
Date/time components.
These are building blocks ONLY — they are interpolated into the anchored matchers below and must stay unanchored. Interpolating a Regex renders it as
(?-imsx:...), so an anchor here would end up buried mid-pattern in the composites (^(?-imsx:^...$)\s+...$) and could never match.Never match user input against these directly — use the INPUT_DATE_* matchers, which are anchored.
Hour is bounded 00-23 and minute 00-59 so the largest representable offset is 23:59 (86340s), which stays inside Time::Location.fixed's +/-24h limit. Without these bounds an offset like -9999 passes the match and then raises Time::Location::InvalidTimezoneOffsetError - a non-CliGen exception that escapes App#handle_command_raises and reaches the user as a stack trace.
-
UINT =
/^[[:digit:]]+$/