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 stringbuilder
s 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
Post a Comment