Skip to main content

All Questions

Tagged with
0 votes
0 answers
30 views

Extract number from string with C# Regex [duplicate]

I want to extract a number from a string in C#. The input string is a single line, but otherwise can be anything. I want to extract with the following rules: The first character can be a minus sign, ...
Rob Cunningham's user avatar
1 vote
4 answers
505 views

How to create a regular expression for numeric strings that should include only 0-9 digits, comma, dot, plus, minus and whitespaces?

I've had one for everything but spaces, that worked great: new Regex("[^0-9-+,.\r]"); But adding spaces seemed to be a problem. I don't need any validity check more than that.
MTZ's user avatar
  • 109
1 vote
1 answer
1k views

Regular expression for single number or groups with addition (+) and subtraction (-) mathematical operator

I need to create a regular expression that only accepts numbers and addition and subtraction characters. I've defined the single number and groups pattern by this way ([1-9][0-9]*) I'm not able to ...
Claudio's user avatar
  • 53
2 votes
4 answers
7k views

Split numeric part from alphanumeric string using C#

I have alphanumeric string list. For example: 1A 2B 7K 10A I want to get only the numeric part and then compare them, if it is less than 10 I need not to add it in another list. What I want to know ...
Iti Tyagi's user avatar
  • 3,681
33 votes
6 answers
45k views

Keep only numeric value from a string?

I have some strings like this string phoneNumber = "(914) 395-1430"; I would like to strip out the parethenses and the dash, in other word just keep the numeric values. So the output could look like ...
meda's user avatar
  • 45.5k
2 votes
5 answers
7k views

c# regular expression only numerical characters in string

I want to check if a string with an undefined length consist of only numbers. Example: "234324" = true "er32" = false "1" = true the way I tried to solve this problem is like this: public bool ...
Marnix v. R.'s user avatar
  • 1,698
2 votes
1 answer
1k views

Regex for numeric characters and .&-

I'm using C# and .NET and I have a Regex that looks like this "\D" That matches all non-numeric characters however I don't want that to match a decimal point (.) and a negative sign (-). How can I ...
Mark Lalor's user avatar
  • 7,907