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
* Replaces the substring after the first occurrence of a specified search string.
831
833
*
834
+
* ## Notes
835
+
*
836
+
* - If unable to find search string, the function returns the input string unchanged.
837
+
* - If `fromIndex` is less than zero, the starting index is resolved relative to the last string character, with the last string character corresponding to `fromIndex = -1`.
838
+
*
832
839
* @param str - input string
833
840
* @param search - search string
834
841
* @param replacement - replacement string
@@ -861,9 +868,61 @@ interface Namespace {
861
868
*/
862
869
replaceAfter: typeofreplaceAfter;
863
870
871
+
/**
872
+
* Replaces the substring after the last occurrence of a specified search string.
873
+
*
874
+
* ## Notes
875
+
*
876
+
* - The function scans a provided string from the starting index to the beginning of the string (i.e., backward).
877
+
* - If unable to find search string, the function returns the input string unchanged.
878
+
* - If `fromIndex` is less than zero, the starting index is resolved relative to the last string character, with the last string character corresponding to `fromIndex = -1`.
879
+
*
880
+
* @param str - input string
881
+
* @param search - search string
882
+
* @param replacement - replacement string
883
+
* @param fromIndex - index from which to start searching
884
+
* @returns output string
885
+
*
886
+
* @example
887
+
* var str = 'beep boop';
888
+
* var out = ns.replaceAfterLast( str, ' ', 'foo', str.length );
889
+
* // returns 'beep foo'
890
+
*
891
+
* @example
892
+
* var str = 'beep boop';
893
+
* var out = ns.replaceAfterLast( str, 'p', 'foo', str.length );
894
+
* // returns 'beep boopfoo'
895
+
*
896
+
* @example
897
+
* var str = 'Hello World!';
898
+
* var out = ns.replaceAfterLast( str, '', 'foo', str.length );
899
+
* // returns 'Hello World!'
900
+
*
901
+
* @example
902
+
* var str = 'Hello World!';
903
+
* var out = ns.replaceAfterLast( str, 'xyz', 'foo', str.length );
904
+
* // returns 'Hello World!'
905
+
*
906
+
* @example
907
+
* var str = 'beep boop baz';
908
+
* var out = ns.replaceAfterLast( str, 'p b', 'foo', str.length );
909
+
* // returns 'beep boop bfoo'
910
+
*
911
+
* @example
912
+
* var str = 'beep boop baz';
913
+
* var out = ns.replaceAfterLast( str, 'p b', 'foo', 6 );
914
+
* // returns 'beep bfoo'
915
+
*/
916
+
replaceAfterLast: typeofreplaceAfterLast;
917
+
864
918
/**
865
919
* Replaces the substring before the first occurrence of a specified search string.
866
920
*
921
+
* ## Notes
922
+
*
923
+
* - If unable to find search string, the function returns the input string unchanged.
924
+
* - If `fromIndex` is less than zero, the starting index is resolved relative to the last string character, with the last string character corresponding to `fromIndex = -1`.
925
+
*
867
926
* @param str - input string
868
927
* @param search - search string
869
928
* @param replacement - replacement string
@@ -888,6 +947,53 @@ interface Namespace {
888
947
*/
889
948
replaceBefore: typeofreplaceBefore;
890
949
950
+
/**
951
+
* Replaces the substring before the last occurrence of a specified search string.
952
+
*
953
+
* ## Notes
954
+
*
955
+
* - The function scans a provided string from the starting index to the beginning of the string (i.e., backward).
956
+
* - If unable to find search string, the function returns the input string unchanged.
957
+
* - If `fromIndex` is less than zero, the starting index is resolved relative to the last string character, with the last string character corresponding to `fromIndex = -1`.
958
+
*
959
+
* @param str - input string
960
+
* @param search - search string
961
+
* @param replacement - replacement string
962
+
* @param fromIndex - index from which to start searching
963
+
* @returns output string
964
+
*
965
+
* @example
966
+
* var str = 'beep boop';
967
+
* var out = ns.replaceBeforeLast( str, ' ', 'foo', str.length );
968
+
* // returns 'foo boop'
969
+
*
970
+
* @example
971
+
* var str = 'beep boop';
972
+
* var out = ns.replaceBeforeLast( str, 'p', 'foo', str.length );
973
+
* // returns 'foop'
974
+
*
975
+
* @example
976
+
* var str = 'Hello World!';
977
+
* var out = ns.replaceBeforeLast( str, '', 'foo', str.length );
978
+
* // returns 'Hello World!'
979
+
*
980
+
* @example
981
+
* var str = 'Hello World!';
982
+
* var out = ns.replaceBeforeLast( str, 'xyz', 'foo', str.length );
983
+
* // returns 'Hello World!'
984
+
*
985
+
* @example
986
+
* var str = 'beep boop baz';
987
+
* var out = ns.replaceBeforeLast( str, 'p b', 'foo', str.length );
988
+
* // returns 'foop baz'
989
+
*
990
+
* @example
991
+
* var str = 'beep boop baz';
992
+
* var out = ns.replaceBeforeLast( str, 'p b', 'foo', 6 );
0 commit comments