# regular expressions

**URL:** https://discussions.unity.com/t/regular-expressions/66635
**Category:** Questions & Answers
**Created:** [March 23, 2013, 12:18am UTC](https://discussions.unity.com/t/regular-expressions/66635 "2013-03-23T00:18:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Alan\_Fletcher](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Alan\_Fletcher](https://discussions.unity.com/u/Alan_Fletcher)
#### Post date: [March 23, 2013, 12:18am UTC](https://discussions.unity.com/t/regular-expressions/66635/1 "2013-03-23T00:18:11Z")

</div>

Hello  
I am using the following regex command to only allow numbers be inputted into a text field

```
Regex rgx = new Regex("[^0-9]"); 

```

` `however this obviously doesnt allow the inputting of positive and negative signs +/-. I would like to be able to input -9 for a negative value but when i do it comes back as 09 instead. Any help in getting the regular expression right would be appreciated.

Thanking You

---

<div class="post-metadata">

### Author: ![Alan\_Fletcher](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@Alan\_Fletcher](https://discussions.unity.com/u/Alan_Fletcher)
#### Post date: [March 23, 2013, 1:05am UTC](https://discussions.unity.com/t/regular-expressions/66635/2 "2013-03-23T01:05:24Z")

</div>

this works for anyone who comes across a similar prob

```
Regex rgx = new Regex("[^-][^0-9]+");

```
