468,120 Members | 1,959 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,120 developers. It's quick & easy.

Regex to remove a letter after a decimal number

I have an app that builds where clauses (its 3rd party) and for some reason
it adds an m after decimal numbers... so I get results like this

[NumberItem] = 45.1234m And [OtherCriteria] Like '123%' And [LastCriteria] =
'45.1234m'

well that 45.1234 should not have an m there... sure this works on data
views filters but not on SQL Server which is what the criteria needs to be
for... any regex's out there that would detect a number then look if there
is an m after it so I could replace that m with nothing but only when its a
standalone number and not like in the LastCritiera filter part? thanks!
Feb 4 '08 #1
2 1666
On Feb 4, 9:05 am, "Smokey Grindel" <nos...@nospam.comwrote:
I have an app that builds where clauses (its 3rd party) and for some reason
it adds an m after decimal numbers... so I get results like this

[NumberItem] = 45.1234m And [OtherCriteria] Like '123%' And [LastCriteria] =
'45.1234m'

well that 45.1234 should not have an m there... sure this works on data
views filters but not on SQL Server which is what the criteria needs to be
for... any regex's out there that would detect a number then look if there
is an m after it so I could replace that m with nothing but only when its a
standalone number and not like in the LastCritiera filter part? thanks!
I'm not that great at regex expressions, but this should match the 'm'
when the number is not enclosed with apostrophes:

(?<=(^|\s)\d*\.\d*)m(?=\s)

You should be able to do a Regex.Replace(...) with that, but you might
want to do some more testing before using it in a production
environment. Like I said, I'm not an expert with regex, just a fool
with Expresso.

http://www.ultrapico.com/Expresso.htm

:-)

Thanks,

Seth Rowe [MVP]

Feb 4 '08 #2
Yeah so am I, I've been here messing with regex's trying to find a good
combo... not always easy when you don't know much about them yet... thanks
though! that gets me started

"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:48**********************************@f10g2000 hsf.googlegroups.com...
On Feb 4, 9:05 am, "Smokey Grindel" <nos...@nospam.comwrote:
>I have an app that builds where clauses (its 3rd party) and for some
reason
it adds an m after decimal numbers... so I get results like this

[NumberItem] = 45.1234m And [OtherCriteria] Like '123%' And
[LastCriteria] =
'45.1234m'

well that 45.1234 should not have an m there... sure this works on data
views filters but not on SQL Server which is what the criteria needs to
be
for... any regex's out there that would detect a number then look if
there
is an m after it so I could replace that m with nothing but only when its
a
standalone number and not like in the LastCritiera filter part? thanks!

I'm not that great at regex expressions, but this should match the 'm'
when the number is not enclosed with apostrophes:

(?<=(^|\s)\d*\.\d*)m(?=\s)

You should be able to do a Regex.Replace(...) with that, but you might
want to do some more testing before using it in a production
environment. Like I said, I'm not an expert with regex, just a fool
with Expresso.

http://www.ultrapico.com/Expresso.htm

:-)

Thanks,

Seth Rowe [MVP]

Feb 5 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by bill tie | last post: by
3 posts views Thread by Mad Scientist Jr | last post: by
6 posts views Thread by Gary Bond | last post: by
10 posts views Thread by igor.kulkin | last post: by
1 post views Thread by AMP | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.