Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ MatchSpecifiedWords()

bool System.__DTString.MatchSpecifiedWords ( string target,
bool checkWordBoundary,
ref int matchLength )
inlinepackage

Definition at line 178 of file __DTString.cs.

179 {
180 int num = Value.Length - Index;
181 matchLength = target.Length;
182 if (matchLength > num || m_info.Compare(Value.Slice(Index, matchLength), target, CompareOptions.IgnoreCase) != 0)
183 {
184 int num2 = 0;
185 int num3 = Index;
186 int num4 = target.IndexOfAny(WhiteSpaceChecks, num2);
187 if (num4 == -1)
188 {
189 return false;
190 }
191 do
192 {
193 int num5 = num4 - num2;
194 if (num3 >= Value.Length - num5)
195 {
196 return false;
197 }
198 if (num5 == 0)
199 {
200 matchLength--;
201 }
202 else
203 {
204 if (!char.IsWhiteSpace(Value[num3 + num5]))
205 {
206 return false;
207 }
208 if (m_info.CompareOptionIgnoreCase(Value.Slice(num3, num5), target.AsSpan(num2, num5)) != 0)
209 {
210 return false;
211 }
212 num3 = num3 + num5 + 1;
213 }
214 num2 = num4 + 1;
215 while (num3 < Value.Length && char.IsWhiteSpace(Value[num3]))
216 {
217 num3++;
218 matchLength++;
219 }
220 }
221 while ((num4 = target.IndexOfAny(WhiteSpaceChecks, num2)) >= 0);
222 if (num2 < target.Length)
223 {
224 int num6 = target.Length - num2;
225 if (num3 > Value.Length - num6)
226 {
227 return false;
228 }
229 if (m_info.CompareOptionIgnoreCase(Value.Slice(num3, num6), target.AsSpan(num2, num6)) != 0)
230 {
231 return false;
232 }
233 }
234 }
235 if (checkWordBoundary)
236 {
237 int num7 = Index + matchLength;
238 if (num7 < Value.Length && char.IsLetter(Value[num7]))
239 {
240 return false;
241 }
242 }
243 return true;
244 }
int Compare(string? string1, string? string2)
int CompareOptionIgnoreCase(ReadOnlySpan< char > string1, ReadOnlySpan< char > string2)
ReadOnlySpan< T > Slice(int start)
readonly CompareInfo m_info
Definition __DTString.cs:14
ReadOnlySpan< char > Value
Definition __DTString.cs:8
static readonly char[] WhiteSpaceChecks
Definition __DTString.cs:18

References System.Globalization.CompareInfo.Compare(), System.Globalization.CompareInfo.CompareOptionIgnoreCase(), System.__DTString.Index, System.ReadOnlySpan< T >.Length, System.__DTString.m_info, System.ReadOnlySpan< T >.Slice(), System.__DTString.Value, and System.__DTString.WhiteSpaceChecks.

Referenced by System.__DTString.MatchLongestWords().