Partager via


AbstractStringBuilder.LastIndexOf Method

Definition

Overloads

LastIndexOf(String)

Returns the index within this string of the last occurrence of the specified substring.

LastIndexOf(String, Int32)

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.

LastIndexOf(String)

Returns the index within this string of the last occurrence of the specified substring.

[Android.Runtime.Register("lastIndexOf", "(Ljava/lang/String;)I", "GetLastIndexOf_Ljava_lang_String_Handler")]
public virtual int LastIndexOf (string? str);
[<Android.Runtime.Register("lastIndexOf", "(Ljava/lang/String;)I", "GetLastIndexOf_Ljava_lang_String_Handler")>]
abstract member LastIndexOf : string -> int
override this.LastIndexOf : string -> int

Parameters

str
String

the substring to search for.

Returns

the index of the last occurrence of the specified substring, or -1 if there is no such occurrence.

Attributes

Remarks

Returns the index within this string of the last occurrence of the specified substring. The last occurrence of the empty string "" is considered to occur at the index value this.length().

The returned index is the largest value k for which:

{@code
            this.toString().startsWith(str, k)
            }

If no such value of k exists, then -1 is returned.

Java documentation for java.lang.AbstractStringBuilder.lastIndexOf(java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to

LastIndexOf(String, Int32)

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.

[Android.Runtime.Register("lastIndexOf", "(Ljava/lang/String;I)I", "GetLastIndexOf_Ljava_lang_String_IHandler")]
public virtual int LastIndexOf (string? str, int fromIndex);
[<Android.Runtime.Register("lastIndexOf", "(Ljava/lang/String;I)I", "GetLastIndexOf_Ljava_lang_String_IHandler")>]
abstract member LastIndexOf : string * int -> int
override this.LastIndexOf : string * int -> int

Parameters

str
String

the substring to search for.

fromIndex
Int32

the index to start the search from.

Returns

the index of the last occurrence of the specified substring, searching backward from the specified index, or -1 if there is no such occurrence.

Attributes

Remarks

Returns the index within this string of the last occurrence of the specified substring, searching backward starting at the specified index.

The returned index is the largest value k for which:

{@code
                k <= Math.min(fromIndex, this.length()) &&
                              this.toString().startsWith(str, k)
            }

If no such value of k exists, then -1 is returned.

Java documentation for java.lang.AbstractStringBuilder.lastIndexOf(java.lang.String, int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to