Click here to Skip to main content
13,295,051 members (85,034 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hi all,
my string a="A0001".
How i get the value "0001"

Thanks in advance
Posted 25-Dec-12 2:05am
Krunal Rohit 25-Dec-12 7:08am
be clear with your issue..
Manojit Mondal 25-Dec-12 7:13am
i have a string a ="A0001". i want to cut "A" word.
Zoltán Zörgő 25-Dec-12 7:13am
What about String.Substring?
string cuted=a.Substring(1);
Manojit Mondal 25-Dec-12 7:15am
please be specific.
Zoltán Zörgő 25-Dec-12 7:16am
Me? How to be more specific?
Manojit Mondal 25-Dec-12 7:22am
sorry at 1st i did not see your example.
Manojit Mondal 25-Dec-12 7:20am
thanks it works.......
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Exactly how you do this will depend on what your data format is like. If it is always "one character, followed by four numerics, then it is trivial:
string inp = "A0001";
string alpha = inp.Substring(0,1);
string numeric = inp.Substring(1);
If on the other hand it is a variable length non-numeric at the front, then you would be better off using a Regex:
string inp = "A0001";
Regex regex = new Regex(@"(?<Alpha>[^\d]*)(?<Numeric>\d+)");
Match m = regex.Match(inp);
string alpha = m.Groups["Alpha"].Value;
string numeric = m.Groups["Numeric"].Value;
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Hi , try next:
string a="A0001";
char[] array=a.ToCharArray();
var accumulator=new StringBuilder();
foreac(c in array)
string result =accumulator.ToString();
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

string a="A0001";
a = a.split('A')[0].ToString();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171207.1 | Last Updated 25 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100