asp.net - error StartIndex cannot be less than zero -


hi guys new regex world think have code on have work can make modification code doing have find ticket number list of string got error length cannot less 0 add check when add check on got error startindex can not less 0 writing code details

my aspx.cs page:

using system.windows.forms; using system.data; namespace aqcconsolidator1 { public partial class form1 : form {     private void btngetdata_click(object sender, eventargs e)     {         list<string> list = new list<string>();         list<string> list1 = new list<string>();          string history = @"rp/dca1s219c/dca1s219c            sl/su   7feb13/2215z   8txsak                   36 fa pax 125-7239038457/etba/07feb13/dca1s211e/49881134                           /s4-5/p3                                                                   37 fa pax 125-7239038458/etba/07feb13/dca1s211e/49881134                           /s4-5/p1                                                                   38 fa pax 125-7239038459/etba/07feb13/dca1s211e/49881134                           /s4-5/p2                                                                    023 af/fa 125-7239038457/etba/07feb13/dca1s211e/49881134/ba                      272 n 24jun sanlhr/ba 273 n 07aug lhrsan/macdorman/sam                       corbin(chd)                                                                023 af/fa 125-7239038458/etba/07feb13/dca1s211e/49881134/ba                      272 n 24jun sanlhr/ba 273 n 07aug lhrsan/loj/danuta                          isabella                                                                   023 af/fa 125-7239038459/etba/07feb13/dca1s211e/49881134/ba                      272 n 24jun sanlhr/ba 273 n 07aug lhrsan/macdorman/jack                      henry                                                                      023 rf-rh cr-dca1s211e 49881134 gs 1003rh/ro-67ecdab1 dca1s2                     10w 49592222 07feb0628z ";          string histroy1 = @"rp/dca1s219c/dca1s219c            sl/su   5apr13/2119z   23zebk                     42 fa pax 220-7242648582-83/etlh/usd1166.75/04apr13/dca1s211e/4                    9881134/s3-7/p1                                                              43 fa pax 220-7242648584-85/etlh/usd1166.75/04apr13/dca1s211e/4                    9881134/s3-7/p2                                                              022 af/fa 220-7242636221-22/etlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/sabaheta(adt)                                 022 af/fa 220-7242636223-24/etlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/fejzo(adt)                                    022 rf-ws-nmc-us/wstngtng cr-nyc1s21dd 33895934 su 9999ws/ro                     -9c9482e6 nycw33tng 00000000 04apr0223z                                   022/033 xf/fa 220-7242636221-22/etlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/sabaheta(adt)                                 033 af/fa 220-7242636221-22/evlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                      )>md  rp/dca1s219c/dca1s219c            sl/su   5apr13/2119z   23zebk                      lh1730 t 18jul mucsjj/tresnjo/sabaheta(adt)                              033 rf-2g-nyc1s21sp/00102g cr-nyc1s21dd 33895934 gs 00102g/r                     o-67ed3fee nyc1s21sp 33608293 04apr0514z                                 022/034 xf/fa 220-7242636223-24/etlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/fejzo(adt)                                    034 af/fa 220-7242636223-24/evlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/fejzo(adt)                                    034 rf-2g-nyc1s21sp/00102g cr-nyc1s21dd 33895934 gs 00102g/r                     o-67ed3fee nyc1s21sp 33608293 04apr0514z                                  033/035 xf/fa 220-7242636221-22/evlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/sabaheta(adt)                               034/035 xf/fa 220-7242636223-24/evlh/usd1166.75/03apr13/                             nyc1s21dd/33895934/ou 341 s 13may sjjzag/lh6001 t 13may                      zagfra/lh 402 t 13may fraewr/lh7608 t 17jul ewrmuc/                          lh1730 t 18jul mucsjj/tresnjo/fejzo(adt)                                         string history2 = @"rp/dca1s219c/dca1s219c            sl/su   9apr13/2223z   4yytr7                   45 fa pax 257-7242858184/etos/usd736.23/08apr13/dca1s211e/49881                    134/s3-6/p1                                                                46 fa pax 257-7242858185/etos/usd736.23/08apr13/dca1s211e/49881                    134/s3-6/p2                                                                 030 af/fa 257-7242215364/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/os                      088 l 09jun jfkvie/os 847 l 10jun vietia/mbyeti/petraq(                      adt)                                                                       030 af/fa 257-7242215365/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/os                      088 l 09jun jfkvie/os 847 l 10jun vietia/mbyeti/jorgjie(                     adt)                                                                        030 rf-ws-nmc-us/wstmtftp cr-dca1s219c 49881134 su 9999ws/ro                     -9ccf46ce tngw33tmt 00000000 07apr1829z                                    030/035 cf/fa 257-7242215364/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 088 l 09jun jfkvie/os                      087 k 31may viejfk/os 847 l 10jun vietia/mbyeti/petraq(                      adt)                                                                      030/035 af/fa 257-7242215364/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/                        mbyeti/petraq(adt)                                                        )>md   rp/dca1s219c/dca1s219c            sl/su   9apr13/2223z   4yytr7                    030/035 cf/fa 257-7242215365/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 088 l 09jun jfkvie/os                      087 k 31may viejfk/os 847 l 10jun vietia/mbyeti/jorgjie(                     adt)                                                                       030/035 af/fa 257-7242215365/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/                        mbyeti/jorgjie(adt)                                                         035 rf-p-nyc1s21sp/44744u cr-nyc1s21dd 33895934 gs 44744u/ro                     -67ec76d0 nyc1s21sp 33608293 08apr1143z                                    035/043 xf/fa 257-7242215364/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/                        mbyeti/petraq(adt)                                                         043 af/fa 257-7242215364/evos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/                        mbyeti/petraq(adt)                                                          043 rf-sg cr-dca1s211e 49881134 gs 0810sg/ro-67ecdab1 dca1s2                     10w 49592222 08apr1217z                                                   035/045 xf/fa 257-7242215365/etos/usd778.23/07apr13/dca1s219c/                       49881134/os 850 k 31may tiavie/os 087 k 31may viejfk/                        mbyeti/jorgjie(adt)                                                        045 af/fa 257-7242215365/evos/usd778.23/07apr13/dca1s219c/                                      list.add(history);         list.add(histroy1);         list.add(history2);          list1.add(rtq);         list1.add(rtq1);          myclass1 mc = new myclass1();         datatable dt = mc.getnumber(list);     } } 

}

class code::

 using system.data;  using system.text.regularexpressions;  namespace aqcconsolidator1 { class myclass1 {     string output;     string subs;      datatable dt = new datatable();     datarow dr = null;     public datatable getnumber(list<string> request)     {         dt.columns.add("tickitnumber", typeof(string));          foreach (string data in request)         {             string item = data;             while (item.trim() != "")             {                 dr = dt.newrow();                 int r1 = item.indexof("\r", 3);                 if(r1>0)                 {                 subs = item.substring(0, r1);                 }                 if (subs.contains("et"))                 {                     regex regexs = new regex(@"[0-9||-]{14}");                     foreach (match m in regexs.matches(subs))                     {                         output = m.tostring();                         dr["tickitnumber"] = output;                     }                     dt.rows.add(dr);                 }                     item = item.substring(subs.length);                      r1 = item.indexof("\r\n", 0);                      item = item.substring(r1);///error in line startindex cannot less zero.              }         }         return dt;     }  } 

}

try use

if(!string.isnullorempty(item)) {   r1 = item.indexof(environment.newline, 0);   if(r1 >0)     item = item.substring(r1); } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -