|
Finally got a chance to look at the link you provided.
This looks like it will work. I never expected I’d be able to simply locate the desired data based upon its pattern, but I was able to write a RegEx using Expresso that does it (at least on a small sample log).
Now all I need to do is code it and see if it will work for the big files.
Thanks!
David Wilkes
|
|
|
|
|
Also, rereading your original post, you need some grammatical structure here. Read the articles on Yacc, or for .NET anything that is a Yacc-like parser. The article on
http://www.codeproject.com/csharp/minossecc.asp
seems helpful. Search around, I can't put my finger on it but there are other non-Java .NET parsing meta-languages to help with the file structure.
There's always MKS Lex and Yacc -- I've used a long time ago to great effect, not too hard to learn (days). But, find something free if possible.
Cheers.
|
|
|
|
|
I'm overriding an Equals() method in .NET which a type specialization in mind but don't want to kill my code in stupid ways. So:
public override bool Equals(object obj)
{
if ( obj.GetType() == typeof(double) )
// foo
else
return base.Equals(obj)
}
The line to optimize is "if ( obj.GetType() == typeof(double) )". The constant typeof(double) calls is a waste. Tried "if ( obj.GetType().Name == "System.Double" )" with horrible results.
Any optimizations out there? Thx!
|
|
|
|
|
You could store the result of this call to a variable that's used by the comparison.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
if (obj is double) ... else ...
Luc Pattyn
|
|
|
|
|
if (obj is double) wins!
Gives me 2x speed over obj.GetType() == typeof(double).
Thanks!
|
|
|
|
|
As far as performance goes, there are only two rules:
1) shorter code is always faster
2) rule 1 is false
Luc Pattyn
|
|
|
|
|
I didn't think that 'is' would work for a value type ? Or is that just 'as' that won't work ( as it can't return null ) ???
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Sure is is always OK (it produces a bool) whereas as is not.
Luc Pattyn
|
|
|
|
|
Hi, I want to replace any 2 words if found in a line. The 2 words can be on the same line or one on each line.
string line ="hello World, expression";
Regex regx = new Regex("hello"); //how can i optionally put to search either, "hello" and "expression" in a line
if (regx.IsMatch(line))
{
sb.AppendLine(regx.Replace(line, "replaced"));//if "hello" put "H" or if "expression" put "E"
}
Thanks
|
|
|
|
|
You can use the replace method on the string class, you don't need regex for this. There is a RegEx.Replace if you prefer.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hi again!
Last Problem get solved very fast - thx to Luc! This time, i had another problem with printing...
How do i get the last page (number of page) that will be printed at PrintPage - Event?
i want something like that:
Page 1 from 9 (where 9 is last page that will be printed)
i want to print Page x from x on any page... at footer line - anyone does know an solution for?
i did something like that
private int LinesThatFit(PrintPageEventArgs e, PointF curPosition)
{
int CalcSum = (e.MarginBounds.Bottom - (int)curPosition.Y);
int CalcRows = CalcSum / newFont.Height;
return CalcRows;
}
this works - but only for a static height - or better a static font height - i draw a string by DrawString - but if it's wrapped, the LinesThatFit doesn't work correct...
Thx again for any solution - i searched for this problem around 2 days... and found nothing - the LinesThatFit is an own creation... but that was when i just had line for line with none wrapped text!
Hope someone get's it!
Bye!
FreewareFire is in the House!
|
|
|
|
|
put a counter if you are calling your print function last time then use if condition and then
e.Drawstring(.....);
|
|
|
|
|
hi i whant to parse the following code
<br />
<!body><br />
some line<br />
more lines<br />
<!/body><br />
<code><br />
<br />
the following doesnt match<br />
<pre>HtmlSource is the hole content<br />
part is "body"<br />
</pre><br />
<code><br />
string parse = Regex.Match(this.HtmlSource, "<!" + part + ">(.*)<!/" + part + ">").Value;<br />
what does i make wrong ?
greetings gigo
|
|
|
|
|
|
ok the problem is that the query cant run multinline / one option will be to replace all linefeeds but this sucks.
has somebody any idea how can i match over more lines ?
|
|
|
|
|
If you use SingleLine mode, the regex works. Just tested in Expresso
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Is it pssoble to use a VS.net wizard at runtim?
For example I want to use "TableAdapter Configuration Wizard" at runtime to generate Dataset.
|
|
|
|
|
No, it's part of VS.NET, not part of the runtime.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Hello,
I have a listview on my form, but I do not want it to respond to keyboard input as I want to use the keys for something else.
Currently, when the listview is populated with items and I press a key (say, the 'm' key) the listview will change selections to the first item that starts with an M. I would like it not to do that please.
I am guessing this is where I can use 'protected override' (or something like that) however I am new to C# and I haven't grasped that yet.
All help is most appreciated. Thank you
... Andy
photocafe.ca
|
|
|
|
|
I like to find out programatically the users for the printers in C#
That is if you go to start -- settings -- printers and faxes and select a printer and right click
its properties you should find security there.
I want to access the users inside that security and see if a particular user is there programatically.
I did some research and found out that Win32_Printer class can be used to get all the printers connected to
a computer but not able to figure out how to get to the security of it.
Any help is greatly appreciated.
|
|
|
|
|
Hi, I have an windows Form which I don't want user to resize. In VS2003, I remove the minimized, maximize button, set the Locked property to true and everything is OK. Now, I upgraded to VS2005, this don't work anymore. The window can be resized. Is this a bug of VS2005? How can I do it? I tried to set max size and min size to the same and now the form has fixed size. But when I move the cursor to the edge of the form, cusor changed to hint that I am allowed to resize window. It's annoying. So, I don't think this is a good way to do it. Do you guys have any good idea?
Thanks.
|
|
|
|
|
You need to set the frame to be fixed, this is a property on the form, which I don't think has changed.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
|
Thanks. That solves the problem. You guys are great.
|
|
|
|