File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -1109,19 +1109,26 @@ proc defineLibrary*() =
11091109 description = " check if string starts with given prefix" ,
11101110 args = {
11111111 " string" : {String },
1112- " prefix" : {String , Regex }
1112+ " prefix" : {String , Regex , Char }
11131113 },
11141114 attrs = NoAttrs ,
11151115 returns = {Logical },
11161116 example = """
11171117 prefix? "hello" "he" ; => true
11181118 prefix? "boom" "he" ; => false
1119+ ..........
1120+ prefix? "hello" {/\w+/} ; => true
1121+ prefix? "world" {/\d+/} ; => false
1122+ ..........
1123+ prefix? "hello" 'h' ; => true
11191124 """ :
11201125 # =======================================================
1121- if yKind== Regex :
1126+ if likely (yKind== String ):
1127+ push (newLogical (x.s.startsWith (y.s)))
1128+ elif yKind== Regex :
11221129 push (newLogical (x.s.startsWith (y.rx)))
11231130 else :
1124- push (newLogical (x.s.startsWith (y.s) ))
1131+ push (newLogical (x.s.len > 0 and x.s. runeAtPos ( 0 ) == y.c ))
11251132
11261133 builtin " suffix?" ,
11271134 alias = unaliased,
Original file line number Diff line number Diff line change 1- 3341
1+ 3342
You can’t perform that action at this time.
0 commit comments