vb.net - Replace Stripbrackets on RegEx Replace -


i have input string brackets: "[3][4] @ [5]"

and sample datatable result of sql query:

enter image description here

what need replace [i] corresponding cell in column. output should be:

[3][4] @ [5] = "15a circuit breaker #348901836 @ 19-afalcon st. capitol subdivision"

this code:

         dim colstring string          dim arg string          dim remarks string = "[3][4] @ [5]" *this textbox          while not > dtresults.columns.count - 1             rep = "[" & & "]"              colstring = dtresults.columns(i).columnname             arg = regex.replace(remarks, rep, colstring, regexoptions.explicitcapture)             remarks = arg             = + 1         end while 

the problem output contains stripbrackets: "[15a circuit breaker] [#348901836] @ [19-afalcon st. capitol subdivision]"

how explicitly replace string contains stripbracket using regex.replace method?

first of if want value in column of particular row of table, cannot write column name replacement string

colstring = dtresults.columns(i).columnname 

instead use

colstring = dtresults.rows(0).item(i).tostring 

add "\" in replacement string pattern @ beginning shown below:

rep = "\[" & & "]" 

hence final code this:

     dim colstring string      dim arg string      dim remarks string = "[3][4] @ [5]" *this textbox      while not > dtresults.columns.count - 1         rep = "\[" & & "]"          colstring = dtresults.rows(0).item(i).tostring         arg = regex.replace(remarks, rep, colstring, regexoptions.explicitcapture)         remarks = arg         = + 1     end while 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -