ASP.Net VB Separate digit and alphabet -


given string "abc123". how separate them , put variable? example abc stored string variable "a" , 123 stored integer variable "b". thanks!

create 2 stringbuilders accumulate pieces letters , numbers, this:

dim letters new stringbuilder() dim digits new stringbuilder() 

now loop through given string , determine if characters digit or letter, adding appropriate stringbuilder, this:

dim thestring string = "abc123" each c char in thestring     if char.isdigit(c)          digits.append(c)     end if     if char.isletter(c)         letters.append(c)     end if next 

finally, can string representation of each stringbuilder, this:

dim string = letters.tostring() dim b string = digits.tostring() 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

html - Repeat image to extend header to fill screen -

javascript - Backbone.js getting target attribute -