公司名称变化很大,所以我添加了很多或条件。
也许有人用正则表达式来做这件事吗?
我将所需的值存储在不同的组中。
感谢您的帮助!
我只在文本中添加了一部分,完整的文字是大的!希望这对Futur有帮助!链接具有完整的列表。
Unternehmen; Symbol; Valorennummer; Land; Handelswährung; Handels-platform; Indexzugehörigkeit; Papierart; Nennwert; Branche; Kotierungs-segment; Rechnungslegungsnorm; Nächste Generalversammlung; Primär-kotiert; 3M Company; MMM; 1405105; US; CHF; XSWX; ; RS; 0.00; ; International Reporting Standard; ; ; false; 5EL SA; FEL; 632685; CH; CHF; XSWX; ; BS; 40.00; Equity Investment Instruments; International Reporting Standard; IFRS; ; true; ABB Ltd; ABBN; 1222171; CH; CHF; XVTX; SMI,SPI,SLCI,SMIEXP,SLI; RS; 0.12; Industrial Engineering; International Reporting Standard; US GAAP; 13.04.17; true; Abbott Laboratories; ABT; 903037; US; CHF; XSWX; ; RS; 0.00; ; International Reporting Standard; ; ; false; AbbVie Inc; ABBV; 20145667; US; CHF; XSWX; ; RS; 0.00; ; International Reporting Standard; ; ; false; Accu Holding AG; ACUN; 136633; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 10.00; Household Goods; Swiss Reporting Standard; Swiss GAAP FER; ; true; Actelion Ltd.; ATLN; 1053247; CH; CHF; XVTX; SMI,SPI,SLCI,SLIFE,SBIOM,SMIEXP,SLI; RS; 0.50; Pharmaceuticals & Biotechnology; International Reporting Standard; US GAAP; 05.04.17; true; Addex Therapeutics Ltd; ADXN; 2985075; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 1.00; Pharmaceuticals & Biotechnology; International Reporting Standard; IFRS; ; true; Adecco Group AG; ADEN; 1213860; CH; CHF; XVTX; SMI,SPI,SLCI,SMIEXP,SLI; RS; 1.00; Support Services; International Reporting Standard; US GAAP; 20.04.17; true; Adval Tech Holding AG; ADVN; 896792; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 20.00; Industrial Engineering; Swiss Reporting Standard; Swiss GAAP FER; 18.05.17; true; AEVIS VICTORIA SA; AEVS; 1248819; CH; CHF; XSWX; SPI,SSCI,SPIEX,SLIFE,SBIOM; RS; 5.00; Health Care Equipment & Services; Swiss Reporting Standard; Swiss GAAP FER; 13.06.17; true; Airesis SA; AIRE; 1094762; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 0.25; Personal Goods; International Reporting Standard; IFRS; 12.06.17; true; Airopack Technology Group AG; AIRN; 24260694; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 5.00; Technology Hardware & Equipment; Swiss Reporting Standard; Swiss GAAP FER; 10.05.17; true; Allreal Holding AG; ALLN; 883756; CH; CHF; XSWX; SPI,SMCI,SPIEX; RS; 50.00; Real Estate; Immobiliengesellschaften; IFRS; 21.04.17; true; Alpine Select AG; ALPN; 1919955; CH; CHF; XSWX; ; RS; 0.02; Equity Investment Instruments; Investmentgesellschaften; IFRS; 22.05.17; true; Alpiq Holding AG; ALPH; 3438970; CH; CHF; XSWX; ; RS; 10.00; Electricity; International Reporting Standard; IFRS; 18.05.17; true; ALSO Holding AG; ALSN; 2459027; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 1.00; Technology Hardware & Equipment; International Reporting Standard; IFRS; 21.03.17; true; Altin AG; ALTN; 1442452; CH; USD; XSWX; ; RS; 0.03; Equity Investment Instruments; Investmentgesellschaften; IFRS; ; true; ams AG; AMS; 24924656; AT; CHF; XSWX; SPI,SMCI,SPIEX,SMIM,SMIEXP; BS; 0.00; Technology Hardware & Equipment; International Reporting Standard; IFRS; 09.06.17; true; Anglo American plc; AAM; 3186826; GB; CHF; XSWX; ; RS; 0.55; ; International Reporting Standard; ; ; false; APG SGA SA; APGN; 1910702; CH; CHF; XSWX; SPI,SMCI,SPIEX; RS; 2.60; Media; Swiss Reporting Standard; Swiss GAAP FER; 23.05.17; true; Arbonia AG; ARBN; 11024060; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 4.20; Construction & Materials; International Reporting Standard; IFRS; 28.04.17; true; Arundel AG; ARON; 227101; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 9.50; Real Estate; International Reporting Standard; IFRS; 19.09.17; true; ARYZTA AG; ARYN; 4323836; CH; CHF; XVTX; SPI,SMCI,SPIEX,SMIM,SMIEXP,SLI; RS; 0.02; Food Producers; International Reporting Standard; IFRS; 06.12.17; true; Ascom Holding AG; ASCN; 1133920; CH; CHF; XSWX; SPI,SMCI,SPIEX; RS; 0.50; Technology Hardware & Equipment; Swiss Reporting Standard; Swiss GAAP FER; 19.04.17; true; Autoneum Holding AG; AUTN; 12748036; CH; CHF; XSWX; SPI,SMCI,SPIEX; RS; 0.05; Automobiles & Parts; International Reporting Standard; IFRS; 30.03.17; true; Bachem Holding AG; BANB; 1253020; CH; CHF; XSWX; SPI,SSCI,SPIEX,SLIFE; RS; 0.05; Pharmaceuticals & Biotechnology; Swiss Reporting Standard; Swiss GAAP FER; 24.04.17; true; Baker Hughes Incorporated; BHI; 910918; US; CHF; XSWX; ; RS; 1.00; ; International Reporting Standard; ; ; false; Boloise Holding AG; BALN; 1241051; CH; CHF; XVTX; SPI,SMCI,SPIEX,SMIM,SMIEXP,SLI; RS; 0.10; Nonlife Insurance; International Reporting Standard; IFRS; 28.04.17; true; Bank Coop AG; BC; 1811647; CH; CHF; XSWX; SPI,SSCI,SPIEX; BS; 20.00; Banks; Swiss Reporting Standard; Bankengesetz; 20.04.17; true; Bank Linth LLB AG; LINN; 130775; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 20.00; Banks; Swiss Reporting Standard; Bankengesetz; 20.04.17; true; Banque Cantonale de Geneve; BCGE; 35049471; CH; CHF; XSWX; SPI,SSCI,SPIEX; RS; 50.00; Banks; Swiss Reporting Standard; Bankengesetz; 25.04.17; true; Banque Cantonale du Jura SA; BCJ; 3299134; CH; CHF; XSWX; SPI,SSCI,SPIEX; BS; 14.00; Banks; Swiss Reporting Standard; Bankengesetz; 27.04.17; true; Banque Cantonale Vaudoise; BCVN; 1525171; CH; CHF; XSWX; SPI,SMCI,SPIEX; RS; 10.00; Banks; Swiss Reporting Standard; Bankengesetz; 27.04.17; true; Banque Profil de Gestion S.A.; BPDG; 249229; CH; CHF; XSWX; SPI,SSCI,SPIEX; BS; 1.00; General Financial; Swiss Reporting Standard; Bankengesetz; 26.04.17; true; Barry Callebaut AG; BARN; 900296; CH; CHF; XSWX; SPI,SMCI,SPIEX,SMIM,SMIEXP; RS; 7.29; Food Producers; International Reporting Standard; IFRS; 13.12.17; true; Basellandschaftliche Kantonalbank; BLKB; 147355; CH; CHF; XSWX; SPI,SMCI,SPIEX; PC; 100.00; Banks; Swiss Reporting Standard; Bankengesetz; 03.04.17; true; BASF SE; BAS; 11450563; DE; CHF; XSWX; ; RS; 0.00; ; International Reporting Standard; ; ; false; Basilea Pharmaceutica AG; BSLN; 1143244; CH; CHF; XSWX; SPI,SMCI,SPIEX,SLIFE,SBIOM; RS; 1.00; Pharmaceuticals & Biotechnology; International Reporting Standard; US GAAP; 27.04.17; true; Basler Kantonalbank; BSKP; 923646; CH; CHF; XSWX; SPI,SSCI,SPIEX; PC; 8.50; Banks; Swiss Reporting Standard; Bankengesetz; 27.04.17; true; Baxter International Inc.; BAX; 911702; US; CHF; XSWX; ; RS; 1.00; ; International Reporting Standard; ; ; false; BB Biotech AG; BION; 3838999; CH; CHF; XSWX; SLIFE,SBIOM; RS; 0.20; Pharmaceuticals & Biotechnology; Investmentgesellschaften; IFRS; 16.03.17; true; BELIMO Holding AG; BEAN; 150319; CH; CHF; XSWX;
(\w+\s\w+\s\w+\.\w+\.|\w+\s\w+\s\w+\s\w+\.\w+\.|\w+\s\w+\s\w+\.|\w+\s\w+\s\&\s\w+\s\w+|\w+\s\w+\-\w+\-\w+\s\w+|\w+\s\w+\s\w+\s\w+\s\w+|\w+\s\w+\s\w+\s\w+|\w+\s\w+\s\w+|\w+\s\w+);\s(\w+);\s(\d+);\s(\w+);\s(\w+);\s(\w+);
答案 0 :(得分:1)
您的数据与第15项始终是公司名称非常一致:
List<string> items = new List<string>();
int count = 0;
foreach (string s in yourData.Split(';')) {
count++;
if (count == 15) {
items.Add(s);
count = 1;
}
}
MessageBox.Show(string.Join(Environment.NewLine, items.ToArray()));
答案 1 :(得分:0)
这个正则表达式,我认为,至少在眼睛上更容易(恐怖!),似乎解析数据好了:
(?<company>.*?);(?<prefix>.*?);.(?<number>\d*?);(?<code1>.*?);(?<code2>.*?);(?<code3>.*?);.*$
*我们利用数据用分号很好地划分的事实,我们想要第一个&#39;然而很多&#39;字段 - 每个连续和(几乎)相同的命名匹配组表示的字段。
.*?
与&#34;贪婪&#34;相同版本:.*
,但它从匹配none(而不是全部)开始,然后根据需要匹配更多。
答案 2 :(得分:0)
它是公司列表,日期(可选),数字(可选)和bool值 - 全部由&#39;;&#39;
分隔所以...按&#39 ;;&#39;拆分,然后过滤一个简单的正则表达式,以排除已知的非公司名称值:
Regex excludeRegex = new Regex(@"[\d\.]+|true|false", RegexOptions.IgnoreCase);
string dataString = "asd;sdfsdf;f fff; 123.231; true; abb";
List<string> companies = dataString.Split(';',StringSplitOptions.RemoveEmptyEntries)
.Select(c=>c.Trim())
.Where(c=>!excludeRegex.IsMatch(c))
.Distinct()
.ToList();
答案 3 :(得分:0)
看起来像一个模式。
(?m)^\s*([^;]+?)\s*;\s*([^;]+?)\s*;\s*([^;]+?)\s*;\s*([^;]+?)\s*;\s*([^;]+?)\s*;\s*([^;]+?)\s*;(?=.*?(?:true|false);)
(?m)
^ \s*
( [^;]+? ) # (1)
\s* ; \s*
( [^;]+? ) # (2)
\s* ; \s*
( [^;]+? ) # (3)
\s* ; \s*
( [^;]+? ) # (4)
\s* ; \s*
( [^;]+? ) # (5)
\s* ; \s*
( [^;]+? ) # (6)
\s* ;
(?=
.*?
(?: true | false )
;
)