Tiny-Regex

Started by airr, May 01, 2024, 10:51:35 PM

Previous topic - Next topic

airr

Fork with additional options:  https://github.com/ximtech/Regex

MIT License.

AIR.

airr

#1
Yeah, you can tell I had nothing else to do this evening.  ;D

This is an extremely minimalist regex implementation.  No capture groups, etc.

Git repo: https://github.com/kokke/tiny-regex-c


'**************************************************************
' Tiny-Regex-C demo by AIR - 2024-05-01
' Github repo for Tiny-Regex: https://github.com/kokke/tiny-regex-c
'**************************************************************
#include "re.h"

$Pragma comment(lib, "re.lib")

Dim string_to_search$
string_to_search$ = "As we commemorate the 60th anniversary of BASIC, let's raise a glass to Kemeny and Kurtz."
Dim As re_t pattern
Dim As Integer match_idx, match_length

pattern = re_compile("\d+.+C")
match_idx = re_matchp(pattern, string_to_search, &match_length)

If match_idx != -1 Then
    Print "match_idx: ", match_idx, " match_length: ", match_length
    Print Mid$(string_to_search, match_idx+1, match_length), "!"
End If



AIR.