3333/// ))
3434/// ```
3535pub fn compile (
36- regexp : @string . View ,
37- flags ? : @string . View = "" ,
36+ regexp : StringView ,
37+ flags ? : StringView = "" ,
3838) -> Regexp raise RegexpError {
3939 regexp
4040 |> parse (flags = {
@@ -131,7 +131,7 @@ pub fn Regexp::group_names(self : Regexp) -> Array[String] {
131131/// ))
132132/// }
133133/// ```
134- pub fn Regexp ::execute (self : Regexp , input : @string . View ) -> MatchResult {
134+ pub fn Regexp ::execute (self : Regexp , input : StringView ) -> MatchResult {
135135 let captures = vm (self .instructions, input , self .capture)
136136 let (before , after ) = if captures is [0 ..< _ as start , 0 ..< _ as end , ..] {
137137 (input .view (end_offset = start ), input .view (start_offset = end ))
@@ -154,7 +154,7 @@ pub fn Regexp::execute(self : Regexp, input : @string.View) -> MatchResult {
154154///
155155/// Returns: A tuple of
156156/// - `MatchResult` object containing the match status and capture group information.
157- /// - `@string.View ` representing the remaining text after the match.
157+ /// - `StringView ` representing the remaining text after the match.
158158///
159159/// Example:
160160/// ```moonbit
@@ -171,8 +171,8 @@ pub fn Regexp::execute(self : Regexp, input : @string.View) -> MatchResult {
171171#deprecated ("Use `Regexp::execute` and `MatchResult::before`/`after` instead." )
172172pub fn Regexp ::execute_with_remainder (
173173 self : Regexp ,
174- input : @string . View ,
175- ) -> (MatchResult , @string . View ) {
174+ input : StringView ,
175+ ) -> (MatchResult , StringView ) {
176176 let captures = vm (self .instructions, input , self .capture)
177177 if captures is [0 ..< _ as start , 0 ..< _ as end , ..] {
178178 (
@@ -220,7 +220,7 @@ pub fn Regexp::execute_with_remainder(
220220/// inspect(result.after(), content=("xx"))
221221/// assert_true(engine.match_("axxf") is None)
222222/// ```
223- pub fn Regexp ::match_ (self : Regexp , input : @string . View ) -> MatchResult? {
223+ pub fn Regexp ::match_ (self : Regexp , input : StringView ) -> MatchResult? {
224224 let captures = vm (self .instructions, input , self .capture)
225225 guard captures is [0 ..< _ as start , 0 ..< _ as end , ..] else { return None }
226226 let before = input .view (end_offset = start )
@@ -242,11 +242,11 @@ pub fn Regexp::match_(self : Regexp, input : @string.View) -> MatchResult? {
242242/// - Index 4, 5: Start and end positions of the second capture group.
243243/// - And so on...
244244pub struct MatchResult {
245- input : @string . View
245+ input : StringView
246246 captures : Array [Int ]
247247 names : Map [String , Int ]
248- before : @string . View
249- after : @string . View
248+ before : StringView
249+ after : StringView
250250}
251251
252252///|
@@ -294,7 +294,7 @@ pub fn MatchResult::matched(self : Self) -> Bool {
294294/// #|Some("bc")
295295/// ))
296296/// ```
297- pub fn MatchResult ::get (self : Self , index : Int ) -> @string . View ? {
297+ pub fn MatchResult ::get (self : Self , index : Int ) -> StringView ? {
298298 if self .captures.is_empty () ||
299299 index < 0 ||
300300 index >= self .captures.length () / 2 {
@@ -331,7 +331,7 @@ pub fn MatchResult::get(self : Self, index : Int) -> @string.View? {
331331/// ))
332332/// ```
333333///
334- pub fn MatchResult ::groups (self : Self ) -> Map [String , @string . View ] {
334+ pub fn MatchResult ::groups (self : Self ) -> Map [String , StringView ] {
335335 self .names
336336 .iter ()
337337 .filter_map (p => if self .get (p .1 ) is Some (content ) {
@@ -361,7 +361,7 @@ pub fn MatchResult::groups(self : Self) -> Map[String, @string.View] {
361361/// #|[Some("abc"), Some("c")]
362362/// ))
363363/// ```
364- pub fn MatchResult ::results (self : Self ) -> Array [@string . View ? ] {
364+ pub fn MatchResult ::results (self : Self ) -> Array [StringView ? ] {
365365 let results = []
366366 for i = 0 ; i < self .captures.length () / 2 ; i = i + 1 {
367367 let start = self .captures[i * 2 ]
@@ -387,7 +387,7 @@ pub fn MatchResult::results(self : Self) -> Array[@string.View?] {
387387/// let result = engine.execute("say hello")
388388/// inspect(result.before(), content="say hello")
389389/// ```
390- pub fn MatchResult ::before (self : Self ) -> @string . View {
390+ pub fn MatchResult ::before (self : Self ) -> StringView {
391391 self .before
392392}
393393
@@ -403,7 +403,7 @@ pub fn MatchResult::before(self : Self) -> @string.View {
403403/// let result = engine.execute("say yes")
404404/// inspect(result.after(), content="")
405405/// ```
406- pub fn MatchResult ::after (self : Self ) -> @string . View {
406+ pub fn MatchResult ::after (self : Self ) -> StringView {
407407 self .after
408408}
409409
@@ -455,7 +455,7 @@ test "rest method with capture groups" {
455455///|
456456test "rest method usage example" {
457457 let engine = compile ("\\ b\\ w+\\ b" )
458- let mut input : @string . View = "word1 word2 word3"
458+ let mut input : StringView = "word1 word2 word3"
459459 let (result1 , rest1 ) = engine .execute_with_remainder (input )
460460 inspect (
461461 result1 .get (0 ),
0 commit comments