|
Dear Christian! Thanks for your reply. We will try this!
Volker Borm
www.frictionless.de
|
|
|
|
|
Hi all,
I'm trying to write some sort of forum with "forumcode" like snitz. To quote some text, user can surround it with [quote]...[/quote]. To do this I have written this regex:
@"(?<quo_iniTag>\[quote\])(?<quo_text>.*)(?<quo_endTag>\[/quote\])"
and the handler is something like this:
if(m.Groups["quo_iniTag"].Value.Equals("") == false && m.Groups["quo_endTag"].Value.Equals("") == false)
return "####"+m.Groups["quo_text"].Value+"###";
But, sometimes (not always), it hangs forever on the method Replace.
Can you help me please ?
Thanks in advance !
----------------------
!happy coding!
|
|
|
|
|
Can you give an example of a string that causes the regex to hang?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Not it is a big deal, but I would clean the code up a bit by using non-capturing groups for the [quote] and [/quote] because you just want to see if they are there, but don't need them. So the regex string would be:
@"(?:\[quote\])(?<quo_text>.*)(?:\[/quote\])"
if ( m.success )
{
return "####"+m.Groups["quo_text"].Value+"###";
}
then I would change the if statement to a while loop in case the user has more than 1 quote block in a line
string [] s = new string[];
int i = 0;
while ( m.success )
{
s [i] = "####"+m.Groups["quo_text"].Value+"###";
m.NextMatch();
}
return s;
But please send an example of the string that causes it to hang
|
|
|
|
|
my reg ex string did not post correctly it should be
@"(?:\[quote\])(?<quo_text>.*)(?:\[/quote\])"
|
|
|
|
|
I am trying to get the list of Serial ports available in windows system.
Appreciate, if you could lead me to some API's available in C# to retrive the existing ports in the system.
Thnx
SRB
|
|
|
|
|
Here's one:
http://msdn.microsoft.com/msdnmag/issues/02/10/NETSerialComm/default.aspx
Or you can get the .NET framework 2.0 (beta) and use the System.IO.Ports namespace which has everything you need bundled in one managed assembly
|
|
|
|
|
Thanks a bunch whizzs.
I am working on .NET 1.1, so the customized version of this code works for me.
cool
|
|
|
|
|
Hi
I have used one of the typed collection generator tools available for generating type safe .Net collection for my custom object (for example, say customer) . However, I had a question with the Indexof and Contains method. How is it normally implemented? If I pass in a customer object to the contains method or the Indexof method, then for it to function properly, do I need to override the ToString() method for the Customer object so that it returns the key of that object?
Any help is appreciated?
Thanks
|
|
|
|
|
tsramkumar wrote: Indexof and Contains
IIRC, both of them use Equals[^] method to determine equality. The default implementation of Equals in System.Object checks if both references refer to the same object, you might want to override it to define equality in whatever way you want.
If you override Equals, it's recommended to override GetHashCode also, as per this[^] recommendation.
For example,
class Customer
{
int id;
public override bool Equals(object obj)
{
if (obj == null) return false;
Customer b = obj as Customer;
if ((object)b == null) return false;
return this.id == b.id;
}
public override int GetHashCode()
{
return id;
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks Senthil, that really helps. Btw, if the unique identifier of my custom object is a string (alphanumeric) rather than an int, I cannot override the GetHashCode method right? Can you give me the reason behind your recommendation for overriding this method and where it will be used?
Btw, I got around with this by making the custom object implement the IComprable interface and implement the compareto method which would compare the identifiers adn return if they are equal or not. I am wondering if this is something that is not normally done in this scenario?
Thanks.
|
|
|
|
|
tsramkumar wrote: Can you give me the reason behind your recommendation for overriding this method and where it will be used?
This will be used when you put your custom objects into a Hashtable, or in any associative container. You'd expect to get the same Customer, provided the id is the same, regardless of whether they are two different instances. What I mean is
Hashtable h = new Hashtable();
Customer c1 = new Customer(1);
h[c1] = "Senthil";
...
Customer c2 = new Customer(1);
Console.WriteLine((string)h[c2]);
Users of your class would expect "Senthil", right?
tsramkumar wrote: Btw, I got around with this by making the custom object implement the IComprable interface
I'm not sure if implementing IComparable is enough, does your code work correctly for standard .NET collections like ArrayList?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
For a certain project i need to find the translation and rotation parameters between 2 'almost identical' paired-coordinate arrays.
The source coordinates need to be transformed to the target coordinates, therefore the translation and rotation parameters should be determined.
The Horn alghoritm is one, but i could not find any code regarding this.
Anyone has some info regarding the determination of rigid body transformation parameters?
Thanks,
Jan
|
|
|
|
|
I got my dynamic buttons to work now, however, when the user clicks the button, I want a message to show up saying which button was clicked. Whether it was the first, second, third, etc. however, when I click any button, it just says it was the last button created. Let's say I have three buttons, if I click Button_1 it will still say Button_3 was clicked. Here is what my function looks like.
<br />
<br />
protected void GenericButton_Click(object sender, System.EventArgs e)<br />
{<br />
<br />
<br />
string iden = "";<br />
string passedin = "";<br />
iden = GenericButton.ID;<br />
<br />
<br />
}<br />
|
|
|
|
|
Where does GenericButton come from?
What you should do is take sender and cast it back to a button:
<br />
Button TheButtonThatWasClicked = (Button) Sender;<br />
Then you can access all the properties of that button:
<br />
string name = TheButtonThatWasClicked.Name;<br />
string text = TheButtonThatWasClicked.Text;<br />
object tag = TheButtonThatWasClicked.Tag;<br />
I included Tag there because tag is a handy property of certain controls that you can use to store any object you want and be able to retrieve it later.
|
|
|
|
|
Hi,
I would like to loop through the following XML file to fill a combobox with the client name value. Does anyone know how to do this and where is an example?
FTP
Client>
Client_Name xmlns="Default1" /
/Client
Client
Client_Name xmlns="Default2" /
/Client
/FTP
Thanks in advance.
Stephen
-- modified at 15:36 Tuesday 1st November, 2005
|
|
|
|
|
Create a DataSet Object and then
<br />
ds.readXml("Path");<br />
for (int i=0;i < ds.tables(0).rows.count;i++)<br />
{<br />
cmbClientName.Items.Add(ds.Tables(0).Rows(i).Items("[Client Name]")<br />
}<br />
Regards
Rizwan Ahmed Malik
R A M
-- modified at 0:31 Wednesday 2nd November, 2005
|
|
|
|
|
|
Hello,
I have:
<br />
foreach(DataColumn col in this.dataview.Table.Columns) { <br />
ColumnIndex++;<br />
.<br />
.<br />
. <br />
} <br />
Is there a way of getting the col HeaderText (not col.ColumnName) within this foreach statement?
Thank you.
|
|
|
|
|
DataColumn doesn't have a HeaderText property. What you are probably looking for is the HeaderText of a DataGridColumnStyle. Try something this:
<br />
foreach(DataGridColumnStyle dgcs in MyDataGrid.TableStyles["MyTable"].GridColumnStyles)<br />
{<br />
string headertext = dgcs.HeaderText;<br />
.<br />
.<br />
.<br />
}<br />
-- modified at 16:51 Tuesday 1st November, 2005
|
|
|
|
|
|
I'm trying to find the straight forward way to sort a single array of dates.
string[] datearray = new string[10]
here is a sample...
i want this:
12/27/2005
12/28/2005
01/01/2006
01/02/2006
01/04/2006
01/05/2006
12/29/2005
12/30/2005
12/31/2005
01/03/2006
to look at this:
12/27/2005
12/28/2005
12/29/2005
12/30/2005
12/31/2005
01/01/2006
01/02/2006
01/03/2006
01/04/2006
01/05/2006
any clues?
|
|
|
|
|
Why are you storing them as strings instead of DateTimes?
Jon Sagara
Look at him. He runs like a Welshman. Doesn't he run like a Welshman? Doesn't he? I think he runs like a Welshman.
Sagara.org | Blog | My Articles
|
|
|
|
|
thats all you needed to say... i fixed it. I needed the output in string format so i had a brain fart and started converting it early... thanks
|
|
|
|
|
I'm looking to access some file properties such as the Author and comments. Where is this information stored? Is there a .Net class that allows access?
|
|
|
|