I have UK postcodes data and I would like to sort them alphabeticaly, when I do that the result is as follows;
N10-XX
N1-XX
N2-XX
N3-XX
N4-XX
N5-XX
What I want is that as follows;
N1-XX
N2-XX
N3-XX
N4-XX
N5-XX
N10-XX
Basicaly I need to add 0 at the begining of the number if it is 1 digit. like N1 should be N01 to be able to do that, what is the regexp pattern for that?
Many thanks.
Well if you are bent on using Regex, then this should do it
var text = #"N10-XX
N1-XX
N2-XX
N3-XX
N4-XX
N5-XX";
text = Regex.Replace(text, #"^N(\d)-", "N0$1-", RegexOptions.Multiline);
that said you obviously will be altering the original data, so I am not sure if this is even applicable
If you want to sort numerically, but preserve the original data, then you may need to do something like this
text.Split('\n')
.Select(o => new { Original = o, Normal = Regex.Replace(o, #"^N(\d)-", "N0$1-", RegexOptions.Compiled)})
.OrderBy(o => o.Normal)
.Select(o => o.Original)
I'm not sure from the example which numbers in the post code need to be ordered. here is some regex examples for valid uk post codes http://blogs.creative-jar.com/post/Valid-UK-Postcdoe-formats.aspx. if you incorporate this using the method above you should be able to do it.
Here is a sort function returning original string in natural(?) order.
List<string> list1 = new List<string>{ "N10-XX","N1-XX","N2-XX","N3-XX","N4-XX","N5-XX" };
List<string> list2 = new List<string>() { "File (5).txt", "File (1).txt", "File (10).txt", "File (100).txt", "File (2).txt" };
var sortedList1 = MySort(list1).ToArray();
var sortedList2 = MySort(list2).ToArray();
public static IEnumerable<string> MySort(IEnumerable<string> list)
{
int maxLen = list.Select(s => s.Length).Max();
Func<string, char> PaddingChar = s => char.IsDigit(s[0]) ? ' ' : char.MaxValue;
return
list.Select(s =>
new
{
OrgStr = s,
SortStr = Regex.Replace(s, #"(\d+)|(\D+)", m => m.Value.PadLeft(maxLen, PaddingChar(m.Value)))
})
.OrderBy(x => x.SortStr)
.Select(x => x.OrgStr);
}
Related
I have a bunch of SKUs (stock keeping units) that represent a series of strings that I'd like to create a single Regex to match for.
So, for example, if I have SKUs:
var skus = new[] { "BATPAG003", "BATTWLP03", "BATTWLP04", "BATTWSP04", "SPIFATB01" };
...I'd like to automatically generate the Regex to recognize any one of the SKUs.
I know that I could do simply do "BATPAG003|BATTWLP03|BATTWLP04|BATTWSP04|SPIFATB01", but list of SKUs can be quite lengthy and I'd like to compress the resulting Regex to look like "BAT(PAG003|TW(LP0(3|4)|SP04))|SPIFATB01"
So this is a combinatorics exercise. I want to generate the all of the possible Regex to match any of my input strings, with the view that the shortest is probably the best.
I could, for example, produce any of these:
BATPAG003|BATTWLP03|BATTWLP04|BATTWSP04|SPIFATB01
BAT(PAG003|TW(LP0(3|4)|SP04))|SPIFATB01
BAT(PAG003|TW(LP(03|04)|SP04))|SPIFATB01
B(ATPAG003|ATTW(LP0(3|4)|ATSP04))|SPIFATB01
Any of those would work, but the shortest is probably the one I'd choose.
To start with I've tried to implement this function:
Func<IEnumerable<string>, IEnumerable<string>> regexify = null;
regexify = xs =>
from n in Enumerable.Range(1, 10)
let g = xs.ToArray().Where(s => !String.IsNullOrWhiteSpace(s)).GroupBy(x => new String(x.Take(n).ToArray()), x => new String(x.Skip(n).ToArray()))
let parts = g.SelectMany(x => x.Count() > 1 ? regexify(x).Select(y => x.Key + "(" + String.Join("|", y) + ")") : new [] { x.Key + String.Join("", x) })
let regex = String.Join("|", parts)
orderby regex.Length
select regex;
This takes my source skus and results in a list of possible Regex's, but it's not working. This is the current output:
BATPAG003|BATTWLP03|BATTWLP04|BATTWSP04|SPIFATB01
BATPAG003|BATTWLP03|BATTWLP04|BATTWSP04|SPIFATB01
BATPAG003|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWLP0(3|4)|BATTWSP04|SPIFATB01
BATPAG003|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(03|04)|BATTWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|BATTWSP04|SPIFATB01
BATPAG003|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P03|P04)|BATTWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|BATTWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|BATTWSP04|SPIFATB01
BATPAG003|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP03|LP04|SP04)|BATTW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|BATTW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|BATTW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)|SPIFATB01
BATPAG003|BATT(WLP03|WLP04|WSP04)|BATT(WLP03|WLP04|WSP04)|BATT(WLP03|WLP04|WSP04)|BATT(WLP03|WLP04|WSP04)|BATT(WLP03|WLP04|WSP04)|BATT(WLP03|WLP04|WSP04)|BATT(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|BATT(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|BATT(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|BATT(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|SPIFATB01
BAT(PAG003|TWLP03|TWLP04|TWSP04)|BAT(PAG003|TWLP03|TWLP04|TWSP04)|BAT(PAG003|TWLP03|TWLP04|TWSP04)|BAT(PAG003|TWLP03|TWLP04|TWSP04)|BAT(PAG003|TWLP03|TWLP04|TWSP04)|BAT(PAG003|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWSP04)|BAT(PAG003|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TWSP04)|BAT(PAG003|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TWSP04)|BAT(PAG003|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|BAT(PAG003|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|T(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|T(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|T(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)))|SPIFATB01
BA(TPAG003|TTWLP03|TTWLP04|TTWSP04)|BA(TPAG003|TTWLP03|TTWLP04|TTWSP04)|BA(TPAG003|TTWLP03|TTWLP04|TTWSP04)|BA(TPAG003|TTWLP03|TTWLP04|TTWSP04)|BA(TPAG003|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWSP04)|BA(TPAG003|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TTWSP04)|BA(TPAG003|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TTWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TTWSP04)|BA(TPAG003|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TTW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TTW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|BA(TPAG003|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|TT(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|TT(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|TT(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)))|BA(T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWSP04)|T(PAG003|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TWSP04)|T(PAG003|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TWSP04)|T(PAG003|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|T(PAG003|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|T(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|T(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|T(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))))|SPIFATB01
B(ATPAG003|ATTWLP03|ATTWLP04|ATTWSP04)|B(ATPAG003|ATTWLP03|ATTWLP04|ATTWSP04)|B(ATPAG003|ATTWLP03|ATTWLP04|ATTWSP04)|B(ATPAG003|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWLP0(3|4)|ATTWSP04)|B(ATPAG003|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(03|04)|ATTWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|ATTWSP04)|B(ATPAG003|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P03|P04)|ATTWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|ATTWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|ATTWSP04)|B(ATPAG003|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP03|LP04|SP04)|ATTW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|ATTW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|ATTW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|B(ATPAG003|ATT(WLP03|WLP04|WSP04)|ATT(WLP03|WLP04|WSP04)|ATT(WLP03|WLP04|WSP04)|ATT(WLP03|WLP04|WSP04)|ATT(WLP03|WLP04|WSP04)|ATT(WLP03|WLP04|WSP04)|ATT(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|ATT(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|ATT(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|ATT(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)))|B(AT(PAG003|TWLP03|TWLP04|TWSP04)|AT(PAG003|TWLP03|TWLP04|TWSP04)|AT(PAG003|TWLP03|TWLP04|TWSP04)|AT(PAG003|TWLP03|TWLP04|TWSP04)|AT(PAG003|TWLP03|TWLP04|TWSP04)|AT(PAG003|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWSP04)|AT(PAG003|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TWSP04)|AT(PAG003|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TWSP04)|AT(PAG003|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|AT(PAG003|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|T(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|T(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|T(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))))|B(A(TPAG003|TTWLP03|TTWLP04|TTWSP04)|A(TPAG003|TTWLP03|TTWLP04|TTWSP04)|A(TPAG003|TTWLP03|TTWLP04|TTWSP04)|A(TPAG003|TTWLP03|TTWLP04|TTWSP04)|A(TPAG003|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWLP0(3|4)|TTWSP04)|A(TPAG003|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(03|04)|TTWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TTWSP04)|A(TPAG003|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P03|P04)|TTWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TTWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TTWSP04)|A(TPAG003|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP03|LP04|SP04)|TTW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TTW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TTW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|A(TPAG003|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP03|WLP04|WSP04)|TT(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|TT(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|TT(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|TT(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)))|A(T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP03|TWLP04|TWSP04)|T(PAG003|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWLP0(3|4)|TWSP04)|T(PAG003|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(03|04)|TWLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|TWSP04)|T(PAG003|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P03|P04)|TWL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|TWL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|TWSP04)|T(PAG003|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP03|LP04|SP04)|TW(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|TW(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|TW(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04))|T(PAG003|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP03|WLP04|WSP04)|T(WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WLP0(3|4)|WSP04)|T(WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(03|04)|WLP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|WSP04)|T(WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P03|P04)|WL(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|WL(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|WSP04)|T(W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP03|LP04|SP04)|W(LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|LP0(3|4)|SP04)|W(LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(03|04)|LP(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4))|SP04)|W(L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P03|P04)|L(P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4)|P0(3|4))|L(P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(03|04)|P(0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)|0(3|4)))|SP04)))))|SPIFATB01
It feels very close, and I think I'm slightly doing something wrong.
This works if each SKU id have the same length.
// ...
string regexStr = Calculate(skus);
// ...
public static string Calculate(IEnumerable<string> rest) {
if (rest.First().Length > 0) {
string[] groups = rest.GroupBy(r => r[0])
.Select(g => g.Key + Calculate(g.Select(e => e.Substring(1))))
.ToArray();
return groups.Length > 1 ? "(" + string.Join("|", groups) + ")" : groups[0];
} else {
return string.Empty;
}
}
This is what I finally worked out:
var skus = new[] { "BATPAG003", "BATTWLP03", "BATTWLP04", "BATTWSP04", "SPIFATB01" };
Func<IEnumerable<IGrouping<string, string>>, IEnumerable<string>> regexify = null;
Func<IEnumerable<string>, IEnumerable<string>> generate =
xs =>
from n in Enumerable.Range(2, 20)
let g = xs.GroupBy(x => new String(x.Take(n).ToArray()), x => new String(x.Skip(n).ToArray()))
where g.Count() != xs.Count()
from r in regexify(g)
select r;
regexify = gxs =>
{
if (!gxs.Any())
{
return new [] { "" };
}
else
{
var rs = regexify(gxs.Skip(1)).ToArray();
return
from f in gxs.Take(1)
from z in new [] { String.Join("|", f) }.Concat(f.Count() > 1 ? generate(f) : Enumerable.Empty<string>())
from r in rs
select f.Key + (f.Count() == 1 ? z : $"({z})") + (r != "" ? "|" + r : "");
}
};
Then using this query:
generate(skus).OrderBy(x => x).OrderBy(x => x.Length);
...I got this result:
BAT(PAG003|TW(LP0(3|4)|SP04))|SPIFATB01
BAT(PAG003|TWLP0(3|4)|TWSP04)|SPIFATB01
BA(TPAG003|TTW(LP0(3|4)|SP04))|SPIFATB01
BAT(PAG003|TW(LP(03|04)|SP04))|SPIFATB01
BAT(PAG003|TW(LP03|LP04|SP04))|SPIFATB01
BAT(PAG003|TWLP(03|04)|TWSP04)|SPIFATB01
BATPAG003|BATTW(LP0(3|4)|SP04)|SPIFATB01
BA(TPAG003|TT(WLP0(3|4)|WSP04))|SPIFATB01
BA(TPAG003|TTW(LP(03|04)|SP04))|SPIFATB01
BA(TPAG003|TTW(LP03|LP04|SP04))|SPIFATB01
BA(TPAG003|TTWLP0(3|4)|TTWSP04)|SPIFATB01
BAT(PAG003|TWL(P0(3|4))|TWSP04)|SPIFATB01
BAT(PAG003|TWL(P03|P04)|TWSP04)|SPIFATB01
BATPAG003|BATT(WLP0(3|4)|WSP04)|SPIFATB01
BATPAG003|BATTW(LP(03|04)|SP04)|SPIFATB01
BATPAG003|BATTW(LP03|LP04|SP04)|SPIFATB01
BA(TPAG003|TT(WLP(03|04)|WSP04))|SPIFATB01
BA(TPAG003|TTWLP(03|04)|TTWSP04)|SPIFATB01
BAT(PAG003|TWLP03|TWLP04|TWSP04)|SPIFATB01
BATPAG003|BATT(WLP(03|04)|WSP04)|SPIFATB01
BA(TPAG003|TT(WL(P0(3|4))|WSP04))|SPIFATB01
BA(TPAG003|TT(WL(P03|P04)|WSP04))|SPIFATB01
BA(TPAG003|TT(WLP03|WLP04|WSP04))|SPIFATB01
BA(TPAG003|TTWL(P0(3|4))|TTWSP04)|SPIFATB01
BA(TPAG003|TTWL(P03|P04)|TTWSP04)|SPIFATB01
BATPAG003|BATT(WL(P0(3|4))|WSP04)|SPIFATB01
BATPAG003|BATT(WL(P03|P04)|WSP04)|SPIFATB01
BATPAG003|BATT(WLP03|WLP04|WSP04)|SPIFATB01
BATPAG003|BATTWLP0(3|4)|BATTWSP04|SPIFATB01
BATPAG003|BATTWLP(03|04)|BATTWSP04|SPIFATB01
BA(TPAG003|TTWLP03|TTWLP04|TTWSP04)|SPIFATB01
BATPAG003|BATTWL(P0(3|4))|BATTWSP04|SPIFATB01
BATPAG003|BATTWL(P03|P04)|BATTWSP04|SPIFATB01
The only problem with my approach was computation time. Some of my source lists have nearly 100 SKUs. Some of the runs were taking longer than I care to wait for and had to break it down into smaller chunks and then manually concatenate.
Take the entire list of all of your sku's and make a single ternary tree regex.
When you add or delete sku's, regenerate the regex. Maybe your database
generates on a weekly basis.
This utility makes a regex of 10,000 strings in less than half a second
and size is not important, it could be 300,000 strings.
For example, here is regex of 175,000 word dictionary.
Somewhat similar to this question:
Where do I put the "orderby group.key" in this LINQ statement?
Except I'm using Dynamic.Linq which makes this a bit harder. I have a bunch of data coming from a database and then I'm grouping by some field and then outputing the result. The problem is that the ordering of the groups seems to randomly jump around which isn't very convenient for the end-user. So taking inspiration from the linked question, if I had this:
string[] words = { "boy","car", "apple", "bill", "crow", "brown" };
// note the first non-dynamic select here was just because I don't think dynamic linq
// will support indexing a string like that and it's not an important detail anyway
var wordList = words.Select(w => new {FirstLetter = w[0], Word = w})
.GroupBy("new (FirstLetter)","Word");
foreach(IGrouping<object, dynamic> g in wordList)
{
Console.WriteLine("Words that being with {0}:",
g.Key.ToString().ToUpper());
foreach (var word in g)
Console.WriteLine(" " + word);
}
Console.ReadLine();
How would I get it to order the keys? At least part of the problem is that the dynamic GroupBy returns an IEnumerable. I thought it might be as easy as:
var wordList = words.Select(w => new {FirstLetter = w[0], Word = w})
.GroupBy("new (FirstLetter)","Word")
.OrderBy("Key");
But that gives me a System.ArgumentException (At least one object must implement IComparable.) when it hits the foreach loop.
My actual code in my project is a little more complicated and looks something like this:
var colGroup = row.GroupBy(string.Format("new({0})",
string.Join(",", c)), string.Format("new({0})",
string.Join(",", v)));
Where c is a list of strings that I need to group by and v is a list of strings that I need to select in each group.
Ok - this is one way to do it, but it might be a little to static to be useful. The problem is that I had this part:
.GroupBy("new (FirstLetter)","Word");
Using new because I can't use a value type as a key (I had another question about that: https://stackoverflow.com/a/26022002/1250301). When with the OrderBy("Key") part, the problem is that it doesn't have a way to compare those dynamic types. I could solve it like this:
var wordList = words.Select(w => new {FirstLetter = w[0].ToString(), Word = w})
.GroupBy("FirstLetter","Word")
.OrderBy("Key");
Making the key a string. Or like this:
var wordList = words.Select(w => new {FirstLetter = w[0], Word = w})
.GroupBy("new (FirstLetter as k)","Word")
.OrderBy("Key.k");
Making it order by something (a char) that is comparable.
I can make it work with my actual problem like this (but it's kind of ugly):
var colGroup = row.GroupBy(string.Format("new({0})", string.Join(",", c)),
string.Format("new({0})", string.Join(",", v)))
.OrderBy(string.Join(",", c.Select(ob => string.Format("Key.{0}", ob))));
I am not sure what you are trying to do, but is that syntax even compiling?
try:
string[] words = { "boy","car", "apple", "bill", "crow", "brown" };
var wordList = words.Select(w => new {FirstLetter = w[0], Word = w})
.GroupBy(x => x.FirstLetter, x => x.Word)
.OrderBy(x => x.Key);
How can I get the string from a list that best match with a base string using the Levenshtein Distance.
This is my code:
{
string basestring = "Coke 600ml";
List<string> liststr = new List<string>
{
"ccoca cola",
"cola",
"coca cola 1L",
"coca cola 600",
"Coke 600ml",
"coca cola 600ml",
};
Dictionary<string, int> resultset = new Dictionary<string, int>();
foreach(string test in liststr)
{
resultset.Add(test, Ldis.Compute(basestring, test));
}
int minimun = resultset.Min(c => c.Value);
var closest = resultset.Where(c => c.Value == minimun);
Textbox1.Text = closest.ToString();
}
In this example if I run the code I get 0 changes in string number 5 from the list, so how can I display in the TextBox the string itself?
for exemple : "Coke 600ml" Right now my TextBox just returns:
System.Linq.Enumerable+WhereEnumerableIterator`1
[System.Collections.Generic.KeyValuePair`2[System.String,System.Int32]]
Thanks.
Try this
var closest = resultset.First(c => c.Value == minimun);
Your existing code is trying to display a list of items in the textbox. I looks like it should just grab a single item where Value == min
resultset.Where() returns a list, you should use
var closest = resultset.First(c => c.Value == minimun);
to select a single result.
Then the closest is a KeyValuePair<string, int>, so you should use
Textbox1.Text = closest.Key;
to get the string. (You added the string as Key and changes count as Value to resultset earilier)
There is a good solution in code project
http://www.codeproject.com/Articles/36869/Fuzzy-Search
It can be very much simplified like so:
var res = liststr.Select(x => new {Str = x, Dist = Ldis.Compute(basestring, x)})
.OrderBy(x => x.Dist)
.Select(x => x.Str)
.ToArray();
This will order the list of strings from most similar to least similar.
To only get the most similar one, simply replace ToArray() with First().
Short explanation:
For every string in the list, it creates an anonymous type which contains the original string and it's distance, computed using the Ldis class. Then, it orders the collection by the distance and maps back to the original string, so as to lose the "extra" information calculated for the ordering.
I'm having a string like "a.b.c.d.e".
If I want to get an array like "a.b.c.d.e", "b.c.d.e", "c.d.e", "d.e", "e" in C#. What's the simplest approach?
Something like this will do:
var stringParts = input.Split('.');
var result = Enumerable.Range(0, stringParts.Length)
.Select(i => string.Join(".", stringParts.Skip(i)));
But like I said in my comment, please show the code you came up with and why you want to make it a one-liner, which usually doesn't serve any benefit. This isn't codegolf.
If you really do it with one statement, you can try this:
var str = "a.b.c.d.e";
var parts = str.Split('.')
.Select((x,idx) => new { idx })
.Select(p => string.Join(".",
str.Split('.').Skip(p.idx))).ToList();
This could be more efficient if you use Split first:
var parts = str.Split('.');
var result = parts
.Select((x,idx) => new { idx })
.Select(p => string.Join(".",
parts.Skip(p.idx))).ToList();
You can also do it without creating anonymous type(s), just create an int variable:
int i = 0;
var result = parts
.Select(p => string.Join(".", parts.Skip(i++)))
.ToList();
This is fairly neat:
var text = "a.b.c.d.e";
var results =
text
.Split('.')
.Reverse()
.Scan("", (a, x) => x + "." + a)
.Select(x => x.TrimEnd('.'))
.Reverse();
You do need to add the Microsoft Reactive Extensions Team's "Interactive Extensions" to get the Scan operator. Use NuGet and look for "Ix-Main".
I actually kind of like this question, not necessarily production but a bit of brain-bendy fun:
"a.b.c.d.e".Split('.').Reverse()
.Aggregate(Enumerable.Empty<string>(), (acc, c) =>
acc.Concat(new [] { c+(acc.LastOrDefault()??"") })
).Reverse()
Dotnetfiddle
What this does is move through each character in the split array and build up a new array by prepending the last value in the array with the current character. It's a fairly common functional programming technique.
Well, this is how I might write it.. I know, not "one line", but if you're gonna use (and I do recommend) a method anyway..
IEnumerable<string> AllComponentPartsForward (string s) {
IEnumerable<string> p = s.Split('.');
while (p.Any()) {
yield return string.Join(".", p); // p.ToArray() for .NET 3.5
p = p.Skip(1);
}
}
(I suppose it could be "more efficient" with IndexOf/Substring, but that's also harder for me to write and reason about!)
I have a string containing up to 9 unique numbers from 1 to 9 (myString) e.g. "12345"
I have a list of strings {"1"}, {"4"} (myList) .. and so on.
I would like to know how many instances in the string (myString) are contained within the list (myList), in the above example this would return 2.
so something like
count = myList.Count(myList.Contains(myString));
I could change myString to a list if required.
Thanks very much
Joe
I would try the following:
count = mylist.Count(s => myString.Contains(s));
It is not perfectly clear what you need, but these are some options that could help:
myList.Where(s => s == myString).Count()
or
myList.Where(s => s.Contains(myString)).Count()
the first would return the number of strings in the list that are the same as yours, the second would return the number of strings that contain yours. If neither works, please make your question more clear.
If myList is just List<string>, then this should work:
int count = myList.Count(x => myString.Contains(x));
If myList is List<List<string>>:
int count = myList.SelectMany(x => x).Count(s => myString.Contains(s));
Try
count = myList.Count(s => s==myString);
This is one approach, but it's limited to 1 character matches. For your described scenario of numbers from 1-9 this works fine. Notice the s[0] usage which refers to the list items as a character. For example, if you had "12" in your list, it wouldn't work correctly.
string input = "123456123";
var list = new List<string> { "1", "4" };
var query = list.Select(s => new
{
Value = s,
Count = input.Count(c => c == s[0])
});
foreach (var item in query)
{
Console.WriteLine("{0} occurred {1} time(s)", item.Value, item.Count);
}
For multiple character matches, which would correctly count the occurrences of "12", the Regex class comes in handy:
var query = list.Select(s => new
{
Value = s,
Count = Regex.Matches(input, s).Count
});
try
var count = myList.Count(x => myString.ToCharArray().Contains(x[0]));
this will only work if the item in myList is a single digit
Edit: as you probably noticed this will convert myString to a char array multiple times so it would be better to have
var myStringArray = myString.ToCharArray();
var count = myList.Count(x => myStringArray.Contains(x[0]));