初始化 monorepo: Go后端(7微服务) + Unity客户端(9模块) + 启动器 HTML5原型: Three.js 3D体素世界, Perlin噪声地形, 原版材质, 22种方块 Minecraft创造模式背包: 双栏布局, 拖拽移动物品, 方向性元件引脚 AI助搭策划文档 + 客户端/服务端骨架 + Docker Compose + CI
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
namespace PCL;
|
||||
|
||||
internal static class CrashText
|
||||
{
|
||||
public static string BeforeFirst(
|
||||
string text,
|
||||
string marker,
|
||||
bool ignoreCase = false)
|
||||
{
|
||||
var pos = string.IsNullOrEmpty(marker)
|
||||
? -1
|
||||
: text.IndexOf(marker, _Comparison(ignoreCase));
|
||||
return pos >= 0
|
||||
? text[..pos]
|
||||
: text;
|
||||
}
|
||||
|
||||
public static string AfterFirst(
|
||||
string text,
|
||||
string marker,
|
||||
bool ignoreCase = false)
|
||||
{
|
||||
var pos = string.IsNullOrEmpty(marker)
|
||||
? -1
|
||||
: text.IndexOf(marker, _Comparison(ignoreCase));
|
||||
return pos >= 0
|
||||
? text[(pos + marker.Length)..]
|
||||
: text;
|
||||
}
|
||||
|
||||
public static string AfterLast(
|
||||
string text,
|
||||
string marker,
|
||||
bool ignoreCase = false)
|
||||
{
|
||||
var pos = string.IsNullOrEmpty(marker)
|
||||
? -1
|
||||
: text.LastIndexOf(marker, _Comparison(ignoreCase));
|
||||
return pos >= 0
|
||||
? text[(pos + marker.Length)..]
|
||||
: text;
|
||||
}
|
||||
|
||||
public static string Between(
|
||||
string text,
|
||||
string after,
|
||||
string before,
|
||||
bool ignoreCase = false)
|
||||
{
|
||||
var comparison = _Comparison(ignoreCase);
|
||||
var startPos = string.IsNullOrEmpty(after)
|
||||
? -1
|
||||
: text.LastIndexOf(after, comparison);
|
||||
startPos = startPos >= 0
|
||||
? startPos + after.Length
|
||||
: 0;
|
||||
|
||||
var endPos = string.IsNullOrEmpty(before)
|
||||
? -1
|
||||
: text.IndexOf(before, startPos, comparison);
|
||||
if (endPos >= 0)
|
||||
return text[startPos..endPos];
|
||||
|
||||
return startPos > 0
|
||||
? text[startPos..]
|
||||
: text;
|
||||
}
|
||||
|
||||
private static StringComparison _Comparison(bool ignoreCase)
|
||||
{
|
||||
return ignoreCase
|
||||
? StringComparison.OrdinalIgnoreCase
|
||||
: StringComparison.Ordinal;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user