diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-30 02:12:02 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-30 02:12:02 -0400 |
commit | 49f7c2be366f0b918b68a4cc8e4335ebab0a15ba (patch) | |
tree | 16a9123cdab4863c283050690a6889803e92a92c /src/util/regex.h | |
parent | added tail and head (diff) | |
download | lazysphere-49f7c2be366f0b918b68a4cc8e4335ebab0a15ba.tar.gz lazysphere-49f7c2be366f0b918b68a4cc8e4335ebab0a15ba.tar.bz2 lazysphere-49f7c2be366f0b918b68a4cc8e4335ebab0a15ba.zip |
fix ls and add start of ed
Diffstat (limited to '')
-rw-r--r-- | src/util/regex.h | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/util/regex.h b/src/util/regex.h new file mode 100644 index 0000000..69facc6 --- /dev/null +++ b/src/util/regex.h @@ -0,0 +1,65 @@ +/* + * + * Mini regex-module inspired by Rob Pike's regex code described in: + * + * http://www.cs.princeton.edu/courses/archive/spr09/cos333/beautiful.html + * + * + * + * Supports: + * --------- + * '.' Dot, matches any character + * '^' Start anchor, matches beginning of string + * '$' End anchor, matches end of string + * '*' Asterisk, match zero or more (greedy) + * '+' Plus, match one or more (greedy) + * '?' Question, match zero or one (non-greedy) + * '[abc]' Character class, match if one of {'a', 'b', 'c'} + * '[^abc]' Inverted class, match if NOT one of {'a', 'b', 'c'} -- NOTE: feature is currently broken! + * '[a-zA-Z]' Character ranges, the character set of the ranges { a-z | A-Z } + * '\s' Whitespace, \t \f \r \n \v and spaces + * '\S' Non-whitespace + * '\w' Alphanumeric, [a-zA-Z0-9_] + * '\W' Non-alphanumeric + * '\d' Digits, [0-9] + * '\D' Non-digits + * + * + */ + +#ifndef _TINY_REGEX_C +#define _TINY_REGEX_C + + +#ifndef RE_DOT_MATCHES_NEWLINE +/* Define to 0 if you DON'T want '.' to match '\r' + '\n' */ +#define RE_DOT_MATCHES_NEWLINE 1 +#endif + +#ifdef __cplusplus +extern "C"{ +#endif + + + +/* Typedef'd pointer to get abstract datatype. */ +typedef struct regex_t* re_t; + + +/* Compile regex string pattern to a regex_t-array. */ +re_t re_compile(const char* pattern); + + +/* Find matches of the compiled pattern inside text. */ +int re_matchp(re_t pattern, const char* text, int* matchlength); + + +/* Find matches of the txt pattern inside text (will compile automatically first). */ +int re_match(const char* pattern, const char* text, int* matchlength); + + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef _TINY_REGEX_C */ |