Skip to content

Commit

Permalink
chore: mops bump + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Demali-876 committed Jan 12, 2025
1 parent da25b2f commit 85e35a7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion mops.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "regex"
version = "1.24.0"
version = "2.4.0"
description = "Motoko regex engine for pattern matching on the Internet Computer."
repository = "https://github.com/Demali-876/motoko_regex_engine"
keywords = [ "regex", "pattern", "matching", "search" ]
Expand Down
39 changes: 31 additions & 8 deletions src/test/lib.test.mo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Parser "../Parser";
import Compiler "../Compiler";
import Result "mo:base/Result";
import Types "../Types";
import Regex "../lib"
import Regex "../lib";

actor {
type Pattern = Text;
Expand Down Expand Up @@ -52,9 +52,10 @@ actor {
}
}
};
public query func testMatch(aregextext : Pattern, pattern : Text) : async Result.Result<Types.Match, Types.RegexError> {
public query func testMatch(aregextext : Pattern, t : Text) : async Result.Result<Types.Match, Types.RegexError> {
let regex = Regex.Regex(aregextext, null);
switch (regex.match(pattern)) {
regex.enableDebug(true);
switch (regex.match(t)) {
case (#ok(result)) {
#ok(result)
};
Expand All @@ -63,9 +64,9 @@ actor {
}
}
};
public query func testSearch(aregextext: Pattern, pattern: Text) : async Result.Result<Types.Match, Types.RegexError> {
public query func testSearch(aregextext: Pattern, t: Text) : async Result.Result<Types.Match, Types.RegexError> {
let regex = Regex.Regex(aregextext, null);
switch (regex.search(pattern)) {
switch (regex.search(t)) {
case (#ok(result)) {
#ok(result);
};
Expand All @@ -74,15 +75,37 @@ actor {
};
};
};
public query func testFindAll(aregextext: Pattern, pattern: Text) : async Result.Result<[Types.Match], Types.RegexError> {
public query func testFindAll(aregextext: Pattern, t: Text) : async Result.Result<[Types.Match], Types.RegexError> {
let regex = Regex.Regex(aregextext, null);
switch (regex.findAll(pattern)) {
switch (regex.findAll(t)) {
case (#ok(matches)) {
#ok(matches);
};
case (#err(e)) {
#err(e);
};
};
}
};
public query func testSplit(aregextext: Pattern, t: Text, maxSplit:?Nat): async Result.Result<[Text], Types.RegexError>{
let regex = Regex.Regex(aregextext, null);
switch (regex.split(t, maxSplit)) {
case (#ok(matches)) {
#ok(matches);
};
case (#err(e)) {
#err(e);
};
};
};
public query func testReplace(aregextext: Pattern, t: Text, replacement: Text, maxReplacement:?Nat): async Result.Result<Text, Types.RegexError> {
let regex = Regex.Regex(aregextext, null);
switch (regex.replace(t, replacement, maxReplacement)) {
case (#ok(result)) {
#ok(result);
};
case (#err(e)) {
#err(e);
};
};
};
}

0 comments on commit 85e35a7

Please sign in to comment.