Regular Expression Help on syntax
On Thu, 7 Jan 2010 23:27:01 -0800, Jason
wrote:
Need help on regular expression, where we are trying to grab number values as
well as minus sign if negative. Currently we can grab all the numbers
correctly, just if numbers are negative, we only grab the number not the
number and the minus sign:
Example for:
-10 we get 10 but want -10 of course
I am new to Regular Expressions and have played with the syntax but cannot
get it work properly. Currently we are using
"\D+(\d+)"
I note that your expression will only capture integers. And also will not
capture an integer at the start of a line.
For integers with an optional sign, and to allow capture of positive integers
at the beginning of a line, try:
"[-+]?\b\d+\b"
--ron
|