You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
external concatMany : t array -> t = "concat" [@@bs.send.pipe: t] [@@bs.splice]
147
146
148
147
(** ES2015:
149
148
[endsWith substr str] returns [true] if the [str] ends with [substr], [false] otherwise.
150
149
151
-
@example {[
152
-
endsWith "Script" "BuckleScript" = true;;
153
-
endsWith "Script" "COBOL" = false;;
154
-
]}
150
+
@example {[
151
+
endsWith "Script" "BuckleScript" = true;;
152
+
endsWith "Script" "BuckleShoes" = false;;
153
+
]}
155
154
*)
156
155
external endsWith : t -> bool = "" [@@bs.send.pipe: t]
157
156
158
157
(** [endsWithFrom ending len str] returns [true] if the first [len] characters of [str] end with [ending], [false] otherwise. If [n] is greater than or equal to the length of [str], then it works like [endsWith]. (Honestly, this should have been named [endsWithAt], but oh well.)
159
158
160
-
@example {[
161
-
endsWithFrom "cd" 4 "abcd" = true;;
162
-
endsWithFrom "cd" 3 "abcde" = false;;
163
-
endsWithFrom "cde" 99 "abcde" = true;;
164
-
endsWithFrom "ple" 7 "example.dat" = true;;
165
-
]}
159
+
@example {[
160
+
endsWithFrom "cd" 4 "abcd" = true;;
161
+
endsWithFrom "cd" 3 "abcde" = false;;
162
+
endsWithFrom "cde" 99 "abcde" = true;;
163
+
endsWithFrom "ple" 7 "example.dat" = true;;
164
+
]}
166
165
*)
167
166
external endsWithFrom : t -> int -> bool = "endsWith" [@@bs.send.pipe: t] (** ES2015 *)
168
167
@@ -402,38 +401,251 @@ the offset at which the match begins, and the whole string being matched.
402
401
*)
403
402
external unsafeReplaceBy3 : Js_re.t -> (t -> t -> t -> t -> int -> t -> t [@bs.uncurry]) -> t = "replace" [@@bs.send.pipe: t]
404
403
404
+
(** [search regexp str] returns the starting position of the first match of [regexp] in the given [str], or -1 if there is no match.
405
+
406
+
@example {[
407
+
search [%re "/\\d+/"] "testing 1 2 3" = 8;;
408
+
search [%re "/\\d+/"] "no numbers" = -1;;
409
+
]}
410
+
*)
405
411
external search : Js_re.t -> int = "" [@@bs.send.pipe: t]
406
412
413
+
(** [slice from:n1 to_:n2 str] returns the substring of [str] starting at character [n1] up to but not including [n2]
414
+
415
+
If either [n1] or [n2] is negative, then it is evaluated as [length str - n1] (or [length str - n2].
416
+
417
+
If [n2] is greater than the length of [str], then it is treated as [length str].
418
+
419
+
If [n1] is greater than [n2], [slice] returns the empty string.
external split : t -> t array = "" [@@bs.send.pipe: t]
456
+
457
+
(**
458
+
[splitAtMost delimiter ~limit: n str] splits the given [str] at every occurrence of [delimiter] and returns an array of the first [n] resulting substrings. If [n] is negative or greater than the number of substrings, the array will contain all the substrings.
external splitRegexpLimited : Js_re.t -> int -> t array = "" [@@bs.send.pipe: t]
417
501
[@@ocaml.deprecated "Please use splitByReAtMost"]
418
502
419
-
externalstartsWith : t -> bool="" [@@bs.send.pipe: t] (** ES2015 *)
420
-
externalstartsWithFrom : t -> int -> bool="startsWith" [@@bs.send.pipe: t] (** ES2015 *)
503
+
(** ES2015:
504
+
[startsWith substr str] returns [true] if the [str] starts with [substr], [false] otherwise.
505
+
506
+
@example {[
507
+
startsWith "Buckle" "BuckleScript" = true;;
508
+
startsWith "" "BuckleScript" = true;;
509
+
startsWith "Buckle" "JavaScript" = false;;
510
+
]}
511
+
*)
512
+
external startsWith : t -> bool = "" [@@bs.send.pipe: t]
513
+
514
+
(** ES2015:
515
+
[startsWithFrom substr n str] returns [true] if the [str] starts with [substr] starting at position [n], [false] otherwise. If [n] is negative, the search starts at the beginning of [str].
516
+
517
+
@example {[
518
+
startsWithFrom "kle" 3 "BuckleScript" = true;;
519
+
startsWithFrom "" 3 "BuckleScript" = true;;
520
+
startsWithFrom "Buckle" 2 "JavaScript" = false;;
521
+
]}
522
+
*)
523
+
external startsWithFrom : t -> int -> bool = "startsWith" [@@bs.send.pipe: t]
421
524
525
+
(**
526
+
[substr ~from: n str] returns the substring of [str] from position [n] to the end of the string.
527
+
528
+
If [n] is less than zero, the starting position is the length of [str] - [n].
529
+
530
+
If [n] is greater than or equal to the length of [str], returns the empty string.
531
+
532
+
@example {[
533
+
substr ~from: 3 "abcdefghij" = "defghij"
534
+
substr ~from: (-3) "abcdefghij" = "hij"
535
+
substr ~from: 12 "abcdefghij" = ""
536
+
]}
537
+
*)
422
538
external substr : from:int -> t = "" [@@bs.send.pipe: t]
539
+
540
+
(**
541
+
[substrAtMost ~from: pos ~length: n str] returns the substring of [str] of length [n] starting at position [pos].
542
+
543
+
If [pos] is less than zero, the starting position is the length of [str] - [pos].
544
+
545
+
If [pos] is greater than or equal to the length of [str], returns the empty string.
546
+
547
+
If [n] is less than or equal to zero, returns the empty string.
external substringToEnd : from:int -> t = "substring" [@@bs.send.pipe: t]
427
588
589
+
(**
590
+
[toLowerCase str] converts [str] to lower case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can give different results depending upon context, for example with the Greek letter sigma, which has two different lower case forms when it is the last character in a string or not.
591
+
592
+
@example {[
593
+
toLowerCase "ABC" = "abc";;
594
+
toLowerCase {js|ΣΠ|js} = {js|σπ|js};;
595
+
toLowerCase {js|ΠΣ|js} = {js|πς|js};;
596
+
]}
597
+
*)
428
598
external toLowerCase : t = "" [@@bs.send.pipe: t]
599
+
600
+
(**
601
+
[toLocaleLowerCase str] converts [str] to lower case using the current locale
602
+
*)
429
603
external toLocaleLowerCase : t = "" [@@bs.send.pipe: t]
604
+
605
+
(**
606
+
[toUpperCase str] converts [str] to upper case using the locale-insensitive case mappings in the Unicode Character Database. Notice that the conversion can expand the number of letters in the result; for example the German [ß] capitalizes to two [S]es in a row.
607
+
608
+
@example {[
609
+
toUpperCase "abc" = "ABC";;
610
+
toUpperCase {js|Straße|js} = {js|STRASSE|js};;
611
+
toLowerCase {js|πς|js} = {js|ΠΣ|js};;
612
+
]}
613
+
*)
430
614
external toUpperCase : t = "" [@@bs.send.pipe: t]
615
+
616
+
(**
617
+
[toLocaleUpperCase str] converts [str] to upper case using the current locale
618
+
*)
431
619
external toLocaleUpperCase : t = "" [@@bs.send.pipe: t]
432
620
621
+
(**
622
+
[trim str] returns a string that is [str] with whitespace stripped from both ends. Internal whitespace is not removed.
623
+
624
+
@example {[
625
+
trim " abc def " = "abc def"
626
+
trim "\n\r\t abc def \n\n\t\r " = "abc def"
627
+
]}
628
+
*)
433
629
external trim : t = "" [@@bs.send.pipe: t]
434
630
435
631
(* HTML wrappers *)
632
+
633
+
(**
634
+
[anchor anchorName anchorText] creates a string with an HTML [<a>] element with [name] attribute of [anchorName] and [anchorText] as its content.
0 commit comments