String.LastIndexOfAny メソッド (Char[])
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As String Dim anyOf As Char() Dim returnValue As Integer returnValue = instance.LastIndexOfAny(anyOf)
戻り値
anyOf 内の文字がこのインスタンスで最後に見つかった場所のインデックス位置。anyOf 内の文字が見つからなかった場合は -1。


このメソッドは、インスタンスの最後の文字位置から検索を開始し、anyOf の文字が見つかるか、または最初の文字位置に到達するまで、インスタンスの先頭へ向かって逆方向に検索を実行します。検索では、大文字と小文字が区別されます。
このメソッドは、序数 (カルチャに依存しない) 検索を実行します。この検索方法では、2 つの文字は Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索を実行するには、CompareInfo.LastIndexOf メソッドを使用します。このメソッドを使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字の構成要素が正しい順序で出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます。

特定の文字列から、"is" を構成する任意の文字が最後に出現するインデックス位置を検索するコード例を次に示します。
' Sample for String.LastIndexOfAny(Char[]) Imports System _ Class Sample Public Shared Sub Main() Dim br1 As String = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-" Dim br2 As String = "0123456789012345678901234567890123456789012345678901234567890123456" Dim str As String = "Now is the time for all good men to come to the aid of their party." Dim start As Integer Dim at As Integer Dim target As String = "is" Dim anyOf As Char() = target.ToCharArray() start = str.Length - 1 Console.WriteLine("The last character occurrence from position {0} to 0.", start) Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str) Console.Write("A character in '{0}' occurs at position: ", target) at = str.LastIndexOfAny(anyOf) If at > - 1 Then Console.Write(at) Else Console.Write("(not found)") End If Console.Write("{0}{0}{0}", Environment.NewLine) End Sub 'Main End Class 'Sample ' 'This example produces the following results: 'The last character occurrence from position 66 to 0. '0----+----1----+----2----+----3----+----4----+----5----+----6----+- '0123456789012345678901234567890123456789012345678901234567890123456 'Now is the time for all good men to come to the aid of their party. ' 'A character in 'is' occurs at position: 58 ' ' '
// Sample for String.LastIndexOfAny(Char[]) using System; class Sample { public static void Main() { string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; string br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; string str = "Now is the time for all good men to come to the aid of their party."; int start; int at; string target = "is"; char[] anyOf = target.ToCharArray(); start = str.Length-1; Console.WriteLine("The last character occurrence from position {0} to 0.", start); Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf); if (at > -1) Console.Write(at); else Console.Write("(not found)"); Console.Write("{0}{0}{0}", Environment.NewLine); } } /* This example produces the following results: The last character occurrence from position 66 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 58 */
// Sample for String::LastIndexOfAny(Char[]) using namespace System; int main() { String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; String^ str = "Now is the time for all good men to come to the aid of their party."; int start; int at; String^ target = "is"; array<Char>^anyOf = target->ToCharArray(); start = str->Length - 1; Console::WriteLine( "The last character occurrence from position {0} to 0.", start ); Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); Console::Write( "A character in '{0}' occurs at position: ", target ); at = str->LastIndexOfAny( anyOf ); if ( at > -1 ) Console::Write( at ); else Console::Write( "(not found)" ); Console::Write( "{0}{0}{0}", Environment::NewLine ); } /* This example produces the following results: The last character occurrence from position 66 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 58 */
// Sample for String.LastIndexOfAny(Char[]) import System.*; class Sample { public static void main(String[] args) { String br1 = "0----+----1----+----2----+----3----+----4----+----5----+" + "----6----+-"; String br2 = "01234567890123456789012345678901234567890123456789012345" + "67890123456"; String str = "Now is the time for all good men to come to the aid of " + "their party."; int start; int at; String target = "is"; char anyOf[] = target.ToCharArray(); start = str.get_Length() - 1; Console.WriteLine("The last character occurrence from position {0} " + "to 0.", (Int32)start); Console.Write("{1}{0}", Environment.get_NewLine(), br1); Console.Write("{1}{0}", Environment.get_NewLine(), br2); Console.WriteLine("{1}{0}", Environment.get_NewLine(), str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf); if (at > -1) { Console.Write(at); } else { Console.Write("(not found)"); } Console.Write("{0}{0}{0}", Environment.get_NewLine()); } //main } //Sample /* This example produces the following results: The last character occurrence from position 66 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 58 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


String.LastIndexOfAny メソッド (Char[], Int32)
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As String Dim anyOf As Char() Dim startIndex As Integer Dim returnValue As Integer returnValue = instance.LastIndexOfAny(anyOf, startIndex)
戻り値
anyOf 内の文字がこのインスタンスで最後に見つかった場所のインデックス位置。anyOf 内の文字が見つからなかった場合は -1。


このメソッドは、インスタンスの startIndex の文字位置から検索を開始し、anyOf の文字が見つかるか、または最初の文字位置に到達するまで、インスタンスの先頭へ向かって逆方向に検索を実行します。検索では、大文字と小文字が区別されます。
このメソッドは、序数 (カルチャに依存しない) 検索を実行します。この検索方法では、2 つの文字は Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索を実行するには、CompareInfo.LastIndexOf メソッドを使用します。このメソッドを使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字の構成要素が正しい順序で出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます。

部分文字列から、"is" を構成する任意の文字が最後に出現するインデックス位置を検索するコード例を次に示します。
' Sample for String.LastIndexOfAny(Char[], Int32) Imports System _ Class Sample Public Shared Sub Main() Dim br1 As String = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-" Dim br2 As String = "0123456789012345678901234567890123456789012345678901234567890123456" Dim str As String = "Now is the time for all good men to come to the aid of their party." Dim start As Integer Dim at As Integer Dim target As String = "is" Dim anyOf As Char() = target.ToCharArray() start =(str.Length - 1) / 2 Console.WriteLine("The last character occurrence from position {0} to 0.", start) Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str) Console.Write("A character in '{0}' occurs at position: ", target) at = str.LastIndexOfAny(anyOf, start) If at > - 1 Then Console.Write(at) Else Console.Write("(not found)") End If Console.Write("{0}{0}{0}", Environment.NewLine) End Sub 'Main End Class 'Sample ' 'This example produces the following results: 'The last character occurrence from position 33 to 0. '0----+----1----+----2----+----3----+----4----+----5----+----6----+- '0123456789012345678901234567890123456789012345678901234567890123456 'Now is the time for all good men to come to the aid of their party. ' 'A character in 'is' occurs at position: 12 ' ' '
// Sample for String.LastIndexOfAny(Char[], Int32) using System; class Sample { public static void Main() { string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; string br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; string str = "Now is the time for all good men to come to the aid of their party."; int start; int at; string target = "is"; char[] anyOf = target.ToCharArray(); start = (str.Length-1)/2; Console.WriteLine("The last character occurrence from position {0} to 0.", start); Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf, start); if (at > -1) Console.Write(at); else Console.Write("(not found)"); Console.Write("{0}{0}{0}", Environment.NewLine); } } /* This example produces the following results: The last character occurrence from position 33 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 12 */
// Sample for String::LastIndexOfAny(Char, Int32) using namespace System; int main() { String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; String^ str = "Now is the time for all good men to come to the aid of their party."; int start; int at; String^ target = "is"; array<Char>^anyOf = target->ToCharArray(); start = (str->Length - 1) / 2; Console::WriteLine( "The last character occurrence from position {0} to 0.", start ); Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); Console::Write( "A character in '{0}' occurs at position: ", target ); at = str->LastIndexOfAny( anyOf, start ); if ( at > -1 ) Console::Write( at ); else Console::Write( "(not found)" ); Console::Write( "{0}{0}{0}", Environment::NewLine ); } /* This example produces the following results: The last character occurrence from position 33 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 12 */
// Sample for String.LastIndexOfAny(Char[], Int32) import System.*; class Sample { public static void main(String[] args) { String br1 = "0----+----1----+----2----+----3----+----4----+----5----+" + "----6----+-"; String br2 = "01234567890123456789012345678901234567890123456789012345" + "67890123456"; String str = "Now is the time for all good men to come to the aid of " + "their party."; int start; int at; String target = "is"; char anyOf[] = target.ToCharArray(); start = (str.get_Length() - 1) / 2; Console.WriteLine("The last character occurrence from position {0} " + "to 0.", (Int32)start); Console.Write("{1}{0}", Environment.get_NewLine(), br1); Console.Write("{1}{0}", Environment.get_NewLine(), br2); Console.WriteLine("{1}{0}", Environment.get_NewLine(), str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf, start); if (at > -1) { Console.Write(at); } else { Console.Write("(not found)"); } Console.Write("{0}{0}{0}", Environment.get_NewLine()); } //main } //Sample /* This example produces the following results: The last character occurrence from position 33 to 0. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'is' occurs at position: 12 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


String.LastIndexOfAny メソッド (Char[], Int32, Int32)
アセンブリ: mscorlib (mscorlib.dll 内)

Public Function LastIndexOfAny ( _ anyOf As Char(), _ startIndex As Integer, _ count As Integer _ ) As Integer
Dim instance As String Dim anyOf As Char() Dim startIndex As Integer Dim count As Integer Dim returnValue As Integer returnValue = instance.LastIndexOfAny(anyOf, startIndex, count)
戻り値
anyOf 内の文字がこのインスタンスで最後に見つかった場所のインデックス位置。anyOf 内の文字が見つからなかった場合は -1。


このメソッドは、インスタンスのstartIndex の文字位置から検索を開始し、anyOf の文字が見つかるか、または count の文字位置に到達するまで、インスタンスの先頭へ向かって逆方向で検索を実行します。検索では、大文字と小文字が区別されます。
このメソッドは、序数 (カルチャに依存しない) 検索を実行します。この検索方法では、2 つの文字は Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索を実行するには、CompareInfo.LastIndexOf メソッドを使用します。このメソッドを使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字の構成要素が正しい順序で出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます。

部分文字列から、"aid" を構成する任意の文字が最後に出現するインデックス位置を検索するコード例を次に示します。
' Sample for String.LastIndexOfAny(Char[], Int32, Int32) Imports System _ Class Sample Public Shared Sub Main() Dim br1 As String = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-" Dim br2 As String = "0123456789012345678901234567890123456789012345678901234567890123456" Dim str As String = "Now is the time for all good men to come to the aid of their party." Dim start As Integer Dim at As Integer Dim count As Integer Dim target As String = "aid" Dim anyOf As Char() = target.ToCharArray() start =(str.Length - 1) * 2 / 3 count =(str.Length - 1) / 3 Console.WriteLine("The last character occurrence from position {0} for {1} characters.", start, count) Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str) Console.Write("A character in '{0}' occurs at position: ", target) at = str.LastIndexOfAny(anyOf, start, count) If at > - 1 Then Console.Write(at) Else Console.Write("(not found)") End If Console.Write("{0}{0}{0}", Environment.NewLine) End Sub 'Main End Class 'Sample ' 'This example produces the following results: 'The last character occurrence from position 44 for 22 characters. '0----+----1----+----2----+----3----+----4----+----5----+----6----+- '0123456789012345678901234567890123456789012345678901234567890123456 'Now is the time for all good men to come to the aid of their party. ' 'A character in 'aid' occurs at position: 27 '
// Sample for String.LastIndexOfAny(Char[], Int32, Int32) using System; class Sample { public static void Main() { string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; string br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; string str = "Now is the time for all good men to come to the aid of their party."; int start; int at; int count; string target = "aid"; char[] anyOf = target.ToCharArray(); start = ((str.Length-1)*2)/3; count = (str.Length-1)/3; Console.WriteLine("The last character occurrence from position {0} for {1} characters.", start, count); Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2, str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf, start, count); if (at > -1) Console.Write(at); else Console.Write("(not found)"); Console.Write("{0}{0}{0}", Environment.NewLine); } } /* This example produces the following results: The last character occurrence from position 44 for 22 characters. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'aid' occurs at position: 27 */
// Sample for String::LastIndexOfAny(Char[], Int32, Int32) using namespace System; int main() { String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"; String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456"; String^ str = "Now is the time for all good men to come to the aid of their party."; int start; int at; int count; String^ target = "aid"; array<Char>^anyOf = target->ToCharArray(); start = ((str->Length - 1) * 2) / 3; count = (str->Length - 1) / 3; Console::WriteLine( "The last character occurrence from position {0} for {1} characters.", start, count ); Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1, br2, str ); Console::Write( "A character in '{0}' occurs at position: ", target ); at = str->LastIndexOfAny( anyOf, start, count ); if ( at > -1 ) Console::Write( at ); else Console::Write( "(not found)" ); Console::Write( "{0}{0}{0}", Environment::NewLine ); } /* This example produces the following results: The last character occurrence from position 44 for 22 characters. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'aid' occurs at position: 27 */
// Sample for String.LastIndexOfAny(Char[], Int32, Int32) import System.*; class Sample { public static void main(String[] args) { String br1 = "0----+----1----+----2----+----3----+----4----+----5----+" + "----6----+-"; String br2 = "01234567890123456789012345678901234567890123456789012345" + "67890123456"; String str = "Now is the time for all good men to come to the aid of " + "their party."; int start; int at; int count; String target = "aid"; char anyOf[] = target.ToCharArray(); start = (str.get_Length() - 1) * 2 / 3; count = (str.get_Length() - 1) / 3; Console.WriteLine("The last character occurrence from position {0} " + "for {1} characters.", (Int32)start, (Int32)count); Console.Write("{1}{0}", Environment.get_NewLine(), br1); Console.Write("{1}{0}", Environment.get_NewLine(), br2); Console.WriteLine("{1}{0}", Environment.get_NewLine(), str); Console.Write("A character in '{0}' occurs at position: ", target); at = str.LastIndexOfAny(anyOf, start, count); if (at > -1) { Console.Write(at); } else { Console.Write("(not found)"); } Console.Write("{0}{0}{0}", Environment.get_NewLine()); } //main } //Sample /* This example produces the following results: The last character occurrence from position 44 for 22 characters. 0----+----1----+----2----+----3----+----4----+----5----+----6----+- 0123456789012345678901234567890123456789012345678901234567890123456 Now is the time for all good men to come to the aid of their party. A character in 'aid' occurs at position: 27 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


String.LastIndexOfAny メソッド

名前 | 説明 |
---|---|
String.LastIndexOfAny (Char[]) | Unicode 配列内の指定した 1 つ以上の文字がこのインスタンスで最後に見つかったインデックス位置をレポートします。 .NET Compact Framework によってサポートされています。 |
String.LastIndexOfAny (Char[], Int32) | Unicode 配列内の指定した 1 つ以上の文字がこのインスタンスで最後に見つかったインデックス位置をレポートします。検索は、指定した文字位置から開始されます。 .NET Compact Framework によってサポートされています。 |
String.LastIndexOfAny (Char[], Int32, Int32) | Unicode 配列内の指定した 1 つ以上の文字がこのインスタンスで最後に見つかったインデックス位置をレポートします。検索は指定した文字位置から開始され、指定した数の文字位置が検査されます。 .NET Compact Framework によってサポートされています。 |

Weblioに収録されているすべての辞書からString.LastIndexOfAnyを検索する場合は、下記のリンクをクリックしてください。

- String.LastIndexOfAnyのページへのリンク