Akhil OR
Akhil OR

Reputation: 25

Split digits from a string between two special characters in c#

"Transaction against  Invoice No #100084# entered and 2 more pending"

This is the string and how can i split the digit inside two character(# #) ie:100084

Upvotes: 1

Views: 136

Answers (3)

Santosh Pandey
Santosh Pandey

Reputation: 111

char[] arr=("#100084#").Replace("#","").ToCharArray()

Upvotes: 1

Muhammed Shevil KP
Muhammed Shevil KP

Reputation: 1396

Try using this

string[] values = Regex.Matches(msgText, @"\#.*?\#").Cast<Match>().Select(m => m.Value).ToArray();

EDIT:

msgText is the string input. This array will contain the string with # character. #10824#. you can replace the same

Upvotes: 2

Pawan Nogariya
Pawan Nogariya

Reputation: 8950

"Transaction against Invoice No #100084# entered and 2 more pending".Split('#')[1]

Upvotes: 0

Related Questions