diff options
| author | Tyge Løvset <[email protected]> | 2022-01-11 00:27:44 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-01-11 00:27:44 +0100 |
| commit | af1b2068b39deebfbf723532a2eddc49da61894a (patch) | |
| tree | f26d06d6be52e280bea0f82558e3e040a89b4335 /examples | |
| parent | 14c0c1b9ab2ce6a4f98baf389d712515b7c68933 (diff) | |
| download | STC-modified-af1b2068b39deebfbf723532a2eddc49da61894a.tar.gz STC-modified-af1b2068b39deebfbf723532a2eddc49da61894a.zip | |
Removed regex for now.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/regex1.c | 26 | ||||
| -rw-r--r-- | examples/regex2.c | 26 | ||||
| -rw-r--r-- | examples/regex_match.c | 35 |
3 files changed, 0 insertions, 87 deletions
diff --git a/examples/regex1.c b/examples/regex1.c deleted file mode 100644 index 9b450453..00000000 --- a/examples/regex1.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stc/cstr.h>
-#include <stc/cregex.h>
-
-int main()
-{
- c_auto (cstr, input)
- c_auto (cregex, float_expr)
- {
- float_expr = cregex_new("[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)");
- // Until "q" is given, ask for another number
- while (true)
- {
- printf("Enter float number (q for quit): ");
- cstr_getline(&input, stdin);
-
- // Exit when the user inputs q
- if (cstr_equals(input, "q"))
- break;
-
- if (cregex_is_match(&float_expr, input.str))
- printf("Input is a float\n");
- else
- printf("Invalid input : Not a float\n");
- }
- }
-}
\ No newline at end of file diff --git a/examples/regex2.c b/examples/regex2.c deleted file mode 100644 index 0562af00..00000000 --- a/examples/regex2.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <stc/cregex.h>
-#include <stc/csview.h>
-#include <stc/cstr.h>
-
-int main()
-{
- const char* fnames[] = {"home/foofile.txt", "cool/barfile.txt", "test/bazboy.dat", "hello/zoidberg"};
- c_auto (cregex, re)
- {
- re = cregex_new("([a-z]+)\\/([a-z]+)\\.([a-z]+)");
-
- c_forrange (i, c_arraylen(fnames))
- {
- printf("%s\n", fnames[i]);
- if (cregex_is_match(&re, fnames[i]))
- {
- c_forrange (j, cregex_capture_size(re))
- {
- csview cap; cregex_capture_v(&re, j, &cap);
- printf(" submatch %zu: " c_PRIsv "\n", j, c_ARGsv(cap));
- }
- puts("");
- }
- }
- }
-}
diff --git a/examples/regex_match.c b/examples/regex_match.c deleted file mode 100644 index 72adeb8e..00000000 --- a/examples/regex_match.c +++ /dev/null @@ -1,35 +0,0 @@ -#include <stdio.h>
-#include <stc/csview.h>
-#include <stc/cregex.h>
-#include <stc/crandom.h>
-#define i_val double
-#define i_type Vecu64
-#include <stc/cstack.h>
-#include <time.h>
-
-
-int main()
-{
- // Lets find the first sequence of digits in a string
- const char *s = "Hello numeric world, there are 24 hours in a day, 3600 seconds in an hour."
- " Around 365.25 days a year, and 52 weeks in a year."
- " Boltzmann const: 1.38064852E-23, is very small."
- " Bohrradius is 5.29177210903e-11, and Avogadros number is 6.02214076e23.";
-
- c_auto (cregex, re)
- {
- re = cregex_new("[+-]?([0-9]*\\.)?[0-9]+([Ee][-+]?[0-9]+)?");
- cregex_match match;
- if (cregex_find(&re, s, &match)) {
- printf("Found digits at position %zu-%zu\n", match.start, match.end);
- } else {
- printf("Could not find any digits\n");
- }
-
- csview sv = {0};
- while (cregex_find_next_v(&re, s, &sv)) {
- printf(c_PRIsv " ; ", c_ARGsv(sv));
- }
- puts("");
- }
-}
\ No newline at end of file |
