43 lines
1.1 KiB
C#
43 lines
1.1 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using UnityEngine;
|
|
|
|
public class TextFormat
|
|
{
|
|
public static string ExtractTextFromHtml(string html)
|
|
{
|
|
// 正则表达式用于移除 HTML 标签
|
|
string pattern = @"<[^>]+>";
|
|
|
|
// 替换 HTML 标签,保留文本
|
|
string result = Regex.Replace(html, pattern, "");
|
|
|
|
return result;
|
|
}
|
|
|
|
public static string DateTimeFormat(string dateTime)
|
|
{
|
|
DateTime date = DateTime.Parse(dateTime);
|
|
return date.ToString("yyyy-MM-dd");
|
|
}
|
|
|
|
public static string DateTimeFormat2(string dateTime)
|
|
{
|
|
DateTime date = DateTime.Parse(dateTime);
|
|
return date.ToString("HH:mm");
|
|
}
|
|
|
|
public static string DateTimeFormat3(string dateTime)
|
|
{
|
|
DateTime date = DateTime.Parse(dateTime);
|
|
return date.ToString("HH:mm:ss");
|
|
}
|
|
public static string DateTimeFormat4(string dateTime)
|
|
{
|
|
DateTime date = DateTime.Parse(dateTime);
|
|
return date.ToString("yyyy年MM月dd日");
|
|
}
|
|
}
|