Click here to Skip to main content
15,908,768 members
Home / Discussions / C#
   

C#

 
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 
GeneralRe: Client And Server Chat Pin
tamir9016-Jul-09 22:18
tamir9016-Jul-09 22:18 
Questionstructure and generic collection use with example Pin
engg_sukreet6-Jul-09 19:20
engg_sukreet6-Jul-09 19:20 
AnswerRe: structure and generic collection use with example - TROLL Pin
Mycroft Holmes6-Jul-09 19:44
professionalMycroft Holmes6-Jul-09 19:44 
QuestionUnable to find the report in the manifest resources. Please build the project, and try again PinPopular
Murtuza Husain Miyan Patel6-Jul-09 18:38
professionalMurtuza Husain Miyan Patel6-Jul-09 18:38 
AnswerRe: Unable to find the report in the manifest resources. Please build the project, and try again Pin
bnvrkv0912-Oct-09 0:14
bnvrkv0912-Oct-09 0:14 
AnswerRe: Unable to find the report in the manifest resources. Please build the project, and try again Pin
Said Ali Jalali15-Jan-10 0:15
Said Ali Jalali15-Jan-10 0:15 
AnswerRe: Unable to find the report in the manifest resources. Please build the project, and try again Pin
randu200519-Apr-10 7:57
randu200519-Apr-10 7:57 

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.