Click here to Skip to main content
15,887,875 members
Home / Discussions / C#
   

C#

 
GeneralRe: Replace numbers after the . with other numbers Pin
ksaw1236-Jul-09 22:24
ksaw1236-Jul-09 22:24 
AnswerRe: Replace numbers after the . with other numbers Pin
dan!sh 6-Jul-09 22:31
professional dan!sh 6-Jul-09 22:31 
GeneralRe: Replace numbers after the . with other numbers Pin
ksaw1236-Jul-09 23:27
ksaw1236-Jul-09 23:27 
GeneralRe: Replace numbers after the . with other numbers Pin
dan!sh 6-Jul-09 23:50
professional dan!sh 6-Jul-09 23:50 
GeneralRe: Replace numbers after the . with other numbers Pin
himanshu25617-Jul-09 0:15
himanshu25617-Jul-09 0:15 
GeneralRe: Replace numbers after the . with other numbers Pin
OriginalGriff7-Jul-09 0:20
mveOriginalGriff7-Jul-09 0:20 
GeneralRe: Replace numbers after the . with other numbers Pin
Alan N7-Jul-09 0:01
Alan N7-Jul-09 0:01 
GeneralRe: Replace numbers after the . with other numbers [modified] Pin
Pete O'Hanlon7-Jul-09 0:19
mvePete O'Hanlon7-Jul-09 0:19 
The following regex finds all numbers that conform to the pattern -9.9999, where the first part can have any number of digits (and can be a positive or negative integer), but the part after the period is constrained to 4 digits.
Regex regex = new Regex(
    @"(((?<Start>-?)(?<Part>\d*))(\.\d{4}))",
    RegexOptions.IgnoreCase
    | RegexOptions.Multiline
    | RegexOptions.IgnorePatternWhitespace
    | RegexOptions.Compiled
    );
You can then do a replace on this using the pattern:
${Start}${Part}.0000
This version of the code prevents you from incorrectly grabbing items such as A.1234 or the like.

[Edit]Modified because I didn't have Encode HTML tags when pasting set, and the group tags were hidden

"WPF has many lovers. It's a veritable porn star!" - Josh Smith

As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.


My blog | My articles | MoXAML PowerToys | Onyx



modified on Tuesday, July 7, 2009 6:44 AM

GeneralRe: Replace numbers after the . with other numbers Pin
dan!sh 7-Jul-09 0:32
professional dan!sh 7-Jul-09 0:32 
GeneralRe: Replace numbers after the . with other numbers Pin
Pete O'Hanlon7-Jul-09 0:46
mvePete O'Hanlon7-Jul-09 0:46 
GeneralRe: Replace numbers after the . with other numbers Pin
OriginalGriff7-Jul-09 1:40
mveOriginalGriff7-Jul-09 1:40 
GeneralRe: Replace numbers after the . with other numbers Pin
Pete O'Hanlon7-Jul-09 1:53
mvePete O'Hanlon7-Jul-09 1:53 
Questionhow to create controls @ run time? Pin
CoderForEver6-Jul-09 20:21
CoderForEver6-Jul-09 20:21 
AnswerRe: how to create controls @ run time? Pin
DaveyM696-Jul-09 22:22
professionalDaveyM696-Jul-09 22:22 
JokeRe: how to create controls @ run time? Pin
Rajesh R Subramanian7-Jul-09 0:01
professionalRajesh R Subramanian7-Jul-09 0:01 
GeneralRe: how to create controls @ run time? Pin
PandemoniumPasha7-Jul-09 0:38
PandemoniumPasha7-Jul-09 0:38 
GeneralRe: how to create controls @ run time? Pin
Pete O'Hanlon7-Jul-09 0:58
mvePete O'Hanlon7-Jul-09 0:58 
GeneralRe: how to create controls @ run time? Pin
CoderForEver7-Jul-09 1:48
CoderForEver7-Jul-09 1:48 
GeneralRe: how to create controls @ run time? Pin
DaveyM697-Jul-09 2:04
professionalDaveyM697-Jul-09 2:04 
Questiondetect bluetooth device Pin
nithydurai6-Jul-09 19:56
nithydurai6-Jul-09 19:56 
AnswerRe: detect bluetooth device Pin
Henry Minute6-Jul-09 23:07
Henry Minute6-Jul-09 23:07 
QuestionClient And Server Chat Pin
tamir9016-Jul-09 19:50
tamir9016-Jul-09 19:50 
AnswerRe: Client And Server Chat Pin
PandemoniumPasha6-Jul-09 20:01
PandemoniumPasha6-Jul-09 20:01 
GeneralRe: Client And Server Chat Pin
tamir9016-Jul-09 20:09
tamir9016-Jul-09 20:09 
GeneralRe: Client And Server Chat Pin
PandemoniumPasha6-Jul-09 21:59
PandemoniumPasha6-Jul-09 21:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.