|
Does any one have a decent regular expression for money. I am struggling to get one together, however I need one that matches for something like this:
a dollar sign($)
1-4 digits 1-999
two decimal places 1.50
0
and will allow a blank textbox.
If anyone has a regex for this or could point me to a utility that would do so, your help is greatly appreciated.
thanks
|
|
|
|
|
Maybe this will get you started:
^\${1}\d{1,4}\.\d{2}$
That will match stuff like $123.45. Note that it may not be perfect; please test it thoroughly before putting it into production.
For what it's worth, I don't know much about regular expressions; I simply I generated that using the free Readable Regex[^] library, using the following code:
string pattern = Pattern.With.AtBeginning.Literal("$").Repeat.Exactly(1)
.Digit.Repeat.InRange(1, 4)
.Literal(".")
.Digit.Repeat.Exactly(2).AtEnd.ToString();
|
|
|
|
|
@"(^\$([1-9]\d{0,3}|0)\.\d\d$)|(^$)"
This SHOULD allow
"$1.45"
"$0.00"
"$50.10"
This should NOT allow
"$00.00"
" $0.00"
"0.00"
"$0.0"
I make no warranties.
Jeff
|
|
|
|
|
I recently updated my project with an Automation Layer, which required the assemblies to be signed so they could be added to the GAC. Simple enough (sort off...) and not a problem. Several assemblies serialize data classes to/from disk.
All my AssemblyInfo.cs files contain
[assembly: AssemblyVersion("4.0.*")] and
[assembly: AssemblyDelaySign(false)]
What I find with SN'd assemblies that does not occur with unsigned ones is that my serialized data files want the EXACT (4.0.build.revision) assembly used to create them to be found in the GAC. Hence I have to delete these data files and recreate them. It's not an issue during development but it would be a PITA once the product is deployed.
What I want to be able to do is have the serialized files readable by any build or revision of the relevent assemblies (ie 4.0.*.*).
Can anyone clarify what's happening here. Is this in fact possible, and if so how?
Stewart DIBBS
|
|
|
|
|
When you serialize/deserialize your data, are you using a BinaryFormatter? If so, check out the AssemblyFormat flags on the BinaryFormatter. Set that property to FormatterAssemblyStyle.Simple and you should be good to go.
|
|
|
|
|
I have a c# winforms application that has been running for roughly 4 years. When a particular user control (call it Order) is loaded, the memory consumption (according to task manager, jumps about 25-30 MB. Each time this control is loaded, the memory jumps this much until it nears 100 MB for the application, then will decrease back to 50 or so MB. Also, the control takes 2-3 seconds to load. Both of these metrics are a little high, but acceptable enough that the users do not mind.
In making an enhancement yesterday, I changed a private member variable of type DataTable to a private static DataTable. There was literally no other code change other than updating the usage of this table to reflect a static variable call. When I ran the application, I was astonished that this control now loads in less than a second. Even more, it claims to only consume about 8 MB memory, and each subsequent load no longer increases the memory usage like it used to. At first I didn't trust the performance tool, but it is obvious that the control loads much faster. The table is still initialized and populated when the control is loaded (at least the first time, all future controls share the table)...so the same exact operations are taking place.
I'm not sure why this performance increase happened. I'm hoping that somebody might have some insight to what might be going on in the framework/computer.
Thanks for the help!
- D
|
|
|
|
|
Static variables don't consume less memory that instance variables. (Or at least, the difference is negligible.)
However, make sure you understand static variables vs. instance variables: each time you make a new Order, a new DataTable was created because it is an instance of Order. But if the DataTable was static, then it was created only once, no matter how many Order instances you make.
|
|
|
|
|
Thank you Judah, this is exactly the functionality that I want with the static variable. I am simply loading a collection of products, and this collection won't be changing. Recently I modified this particular program to allow for multiple orders to be created at the same time instead of only one. So to save on memory, I changed this table to static and all of the orders can use it.
The very first order, however, should be where the table gets filled. In that respect, the code is doing exactly as it used to do before I changed the table to static. However, the response time is much faster, and (according to the performance tools) the memory is no longer leaking. This is the part that I am unclear about...what in the world is happening different?
|
|
|
|
|
Memory may leak if you've got something keeping your Order objects alive even after you're done with them. For instance, if the Order is listening for an event from a live object, the Order will stay in memory for as long as the live object is alive.
How many Orders do you create? How much data is contained in the DataTable?
|
|
|
|
|
1 order
1 table - about 15k records in the table
With the items table as a member variable, the order control consumes about 30MB and takes roughly 3 seconds to load.
With the items table as a static member variable, the same order control consumes 7-8MB and takes less than a second to load.
And this is tested on the first loading of the order control since each subsequent load will already have a populated items table and won't try to repopulate it.
|
|
|
|
|
There shouldn't be a reason why memory should change by having the table static isntead of instance, given that you're creating only 1 instance to begin with.
Something else is going on here, but I can't say without really digging into your code.
|
|
|
|
|
No problem...thanks anyways...
Was hoping that the handling of statics in initialization/static heap/garbage collection was causing the results I am seeing and that somebody would recognize it right away.
|
|
|
|
|
I need to access run command through code.
how cn dat b done??
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
Process process = new Process();
process.StartInfo.FileName = "notepad.exe";
process.Start();
|
|
|
|
|
For simple cases you can use the static overload:
Process.Start("notepad.exe");
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
hi,
can u plz tell me the EXE file which is used for Run.
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
Try format.exe c:
Might not fix your problem, but it will fix ours.
only two letters away from being an asset
|
|
|
|
|
You used to be able to
"echo y | format c:"
which really worked good in the AutoExec.bat on Walmart machines.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
d@nish wrote: my work here is done
y sk mr thn?
Lc Pttn [Frm Gdlns] [M rtcls]
ths mnths tps:
- b4 u sk 1 ? hr, srch CP thn Ggl
- th q nd dtl f ur ? rflcts n th ffctvnss f th hlp u r lkl 2 gt
|
|
|
|
|
Please don't use text speak in posts. It's really really annoying. I assume that you do have a full keyboard and that you haven't posted this from a mobile phone.
|
|
|
|
|
hi pete
it mite b annoying bt dis aint da only job i ve on dis earth.
i ve a lot of other stuufs 2 do if u find it annoyin den remmeba my name n dnt access my thread again
n 4 ur kind info i do ve a 2ble ||lel key boards bt i dnt wanna watse my time in hittin all da keys
thanks n regards
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
Pete is right, and because you chose to disregard his message, I'll return the favor to yours in the future.
|
|
|
|
|
hi,
al rite I'll w8 4 ur favour.mean while try to learn some english grammar.
Thanks
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
... wait...
Did you just ask Judah to learn some English grammar?
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
I needs you to learn me some grammer! lolz
|
|
|
|