// Decompiled with JetBrains decompiler
|
// Type: com.softwee.smgw.common.SegmentHelper
|
// Assembly: App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=c1a16487c920c3dc
|
// MVID: 787A2D4B-0A31-4F54-A952-652B33850A5A
|
// Assembly location: C:\Users\Administrator\Desktop\ssss\bin\App_Code.dll
|
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
namespace com.softwee.smgw.common
|
{
|
public class SegmentHelper
|
{
|
public static string Filrate(string srcText)
|
{
|
if (string.IsNullOrEmpty(srcText))
|
return string.Empty;
|
List<string> srcList = new List<string>(Enumerable.Distinct<string>((IEnumerable<string>) srcText.Split(Enumerable.ToArray<char>((IEnumerable<char>) "\r\n;,|"), StringSplitOptions.RemoveEmptyEntries)));
|
List<string> destList;
|
for (destList = new List<string>(); SegmentHelper.Merge(srcList, destList); destList = new List<string>())
|
srcList = destList;
|
StringBuilder stringBuilder = new StringBuilder();
|
foreach (string str in destList)
|
stringBuilder.AppendLine(str);
|
return stringBuilder.ToString();
|
}
|
|
private static bool Merge(List<string> srcList, List<string> destList)
|
{
|
foreach (string str in srcList.ToArray())
|
{
|
if (str.Length > 5)
|
{
|
string s = str.Substring(0, str.Length - 1);
|
if (SegmentHelper.Remove(srcList, s))
|
destList.Add(s);
|
}
|
}
|
destList.AddRange((IEnumerable<string>) srcList);
|
return srcList.Count != destList.Count;
|
}
|
|
private static bool Remove(List<string> srcList, string s)
|
{
|
for (int index = 0; index < 10; ++index)
|
{
|
if (!srcList.Contains(s + (object) index))
|
return false;
|
}
|
for (int index = 0; index < 10; ++index)
|
srcList.Remove(s + (object) index);
|
return true;
|
}
|
}
|
}
|