Author Topic: Tiny-Regex  (Read 233 times)

airr

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Tiny-Regex
« on: May 01, 2024, 10:51:35 PM »
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

Code: [Select]
'**************************************************************
' 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.
« Last Edit: May 13, 2024, 11:15:46 PM by airr »

airr

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Tiny-Regex
« Reply #1 on: May 13, 2024, 11:39:40 PM »
Fork with additional options:  https://github.com/ximtech/Regex

MIT License.

AIR.