|
For some reason it cut out a lot of it....
I'll try it again.
string newphone = Regex.Replace(phone,
@"^((?<country>[1])([ ]|.|-))(\(|\[)?(?<area>\d{3})(\)[ ]?|\][ ]?|.|-)?(?<prefix>\d{3})(.|-|" +
"[ ])?(?<suffix>\d{4})[ ]?(x|X|#|.)?(?<ext>\d{0,5})$",
"${country} (${area}) ${prefix}-${suffix} #${ext}");
Well i can't get it to use the entire expression for some reason... it cuts out prefix and suffix when trying to post as well as a a few things within the expression.
|
|
|
|
|
check the "ignore HTML tags" checkbox.
|
|
|
|
|
Well just in case anyone wants to see it, or use it in the future here it is... Thanks again ed...
<code>
string phone = "1012345678912345";
string newphone = Regex.Replace(phone, @"^((?<country>[1])([ ]|\.|-)?)(\(|\[)?(?<area>\d{3})(\)[ ]?|\][ ]?|\.|-|[ ])?(?<prefix>\d{3})(\.|-|[ ])?(?<suffix>\d{4})[ ]?(x| #|\.)?(?<ext>\d{0,5})$", "${country} (${area}) ${prefix}-${suffix} #${ext}");
newphone = newphone.TrimEnd('#');
newphone = newphone.Trim();
Console.WriteLine(newphone);
</code>
|
|
|
|
|
Excellent routine. It will definitely come in handy.
Thanks,
Ed
|
|
|
|
|
At first glance, I would guess you would have to qualify the periods with \
|
|
|
|
|
Hey perfect that was it... Thanks a lot for your help... I completely forgot periods meant any single character.. stupid me...
|
|
|
|
|
Hi,
I'm still new to C# so please bear with me.
I am trying to write a windows program, and am struggling to find info for the following things :-
1. How to get an event to trigger when the user clicks the mouse button anywhere on the window. I would like a container thats will contain grahics in the end. But when the user clicks the button I would like to get the Co-ors (X/Y) for where the user clicked.
2. I would like to show a flashing icon on the screen at particular X/Y co-ords, then when the Co-Ords have changed it will update and flash in a different place. I would like to have multiple flashes. Be able to add and remove the flashes. I am assuming I would need to create a new class for this object??
Any help or points to articles would be greatly appreciated.
Regards
Tony
|
|
|
|
|
Nooie wrote: But when the user clicks the button I would like to get the Co-ors (X/Y) for where the user clicked.
Look at the MouseClick event of the control, e.g. a Form or a Panel control. The e parameter contains e.X and e.Y
Nooie wrote: 2. I would like to show a flashing icon on the screen at particular X/Y co-ords
Why not drop a picture box where you want to paint the control? Or just paint directly to the control (look at the paint event) and make it flash using a timer. Many articles in this[^] section will show you how to paint to a control.
Hope that's of use.
|
|
|
|
|
Hi Chris,
Sorry I thought I had replied. I've had a good play with what you suggested and its getting better.
Thats what experience is all about, which is what I get from playing.
Again many thanks for your reply.
Tony
|
|
|
|
|
Hi!
I'm experiencing serialization problems with the .NET XML Serializer on a dictionary datatype:
8<===================================================
...
[Serializable]
public class StringPair
{
public StringPair()
{
m_Key = null; m_Value = null;
}
public StringPair(string p_Key, string p_Value)
{
m_Key = p_Key; m_Value = p_Value;
}
[XmlAttribute("Key")]
public string Key
{
get { return m_Key; }
set { m_Key = value; }
}
[XmlAttribute("Value")]
public string Value
{
get { return m_Value; }
set { m_Value = value; }
}
private string m_Key;
private string m_Value;
}
[Serializable]
public class StringsTable : Dictionary<string, string>, ISerializable, IDeserializationCallback
{
private SerializationInfo _savedSI;
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
{
string[] keys = new string[Count];
string[] values = new string[Count];
int i = 0;
foreach (string l_Key in Keys)
{
keys[i] = l_Key;
values[i] = this[l_Key];
++i;
}
info.AddValue("Keys", keys);
info.AddValue("Values", values);
}
public StringsTable()
{
}
protected StringsTable(SerializationInfo info, StreamingContext context)
{
_savedSI = info;
}
void IDeserializationCallback.OnDeserialization(Object sender)
{
string[] keys = (string[])_savedSI.GetValue("Keys", typeof(string[]));
string[] values = (string[])_savedSI.GetValue("Values", typeof(string[]));
for (Int32 i = 0; i < keys.Length; ++i)
Add(keys[i], values[i]);
_savedSI = null;
}
}
[Serializable]
public class Instance
{
public Instance()
{
m_Vars = new StringsTable();
}
[XmlElement("VariableAssignments"]
public StringsTable Variables
{
get
{
return m_Variables;
}
set
{
m_Variables = value;
}
}
private StringsTable m_Vars;
}
...
8<===================================================
This code compiles without any hassles in Visual C# Express 2005. When Serializing an "Instance" object, I always get an InvalidOperationException telling me that "There was an error reflecting type 'Instance'".
What's wrong with my de-/serializatoin?
Thanks in advance,
Rainer
|
|
|
|
|
I need urgent help.
here is my problem.
for the first 2 columns i fetched records from back end through sql query
GroupCode Plan
1 H1
1 H2
3 F1
4 D1
1 H3
4 D2
3 F2
3 F3
I have to add one more column manually
I would like to display
GroupCode Plan Order
1 H1 1
1 H22 2
3 F1 1
4 D1 1
1 H43 3
4 D2 2
3 F55 2
3 F41 3
How do we do it in c#.
Thanks
|
|
|
|
|
You need to add the column to your datatable, then bind to it as normal.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
Homework time again.
This is so similar to previous posts I've seen, maybe the professor needs to update his/her lesson plans
only two letters away from being an asset
|
|
|
|
|
Mark Nischalke wrote: similar to previous posts I've seen, maybe the professor needs to update his/her lesson plans
|
|
|
|
|
if inside the ctor of a class i have a local variable the type of which is another user-defined class, does it reside in the stack or the heap?
|
|
|
|
|
The reference will be on the stack, the object will be on the heap.
|
|
|
|
|
When I implement an interface explicitly like this
<br />
int IComparable<byte>.CompareTo(byte other)<br />
{<br />
...<br />
}<br />
I am unable to call it my self from another class, it does not show up in intellisence. Is this normal, if so why is it like this? I know that when I implement an interface like this is becomes explicitly public but I still cannot call it. This is for a value type also (I dont know if that makes any difference or not).
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
did you try something like:
class A:IComparable
{
}
______________________________________
A a = new A();
IComparable ia = a as IComparable;
if (ia!=null)
ia.ComapreTo(...);
I don't know if it'll work...you can try it
|
|
|
|
|
Explicit interface implementation allows you to implement an interface without adding public methods to your class. You will be able to call the method by casting an object instance to the interface type.
((IComparable)myInstance).CompareTo(other)
This is mainly used in two cases:
- there is another public method that does the same job and should be called instead (FileStream.Close vs IDisposable.Dispose)
- the method is expected to be only called by some other code that always operates on the interface and doesn't know about your class, and you don't want that the methods show when using your object. (often used with ICustomTypeDescriptor)
|
|
|
|
|
Daniel Grunwald wrote: You will be able to call the method by casting an object instance to the interface type.
((IComparable)myInstance).CompareTo(other)
I remember now. I did this last night...
IComparable<range> test = this;
test.[Intellisence found it];
It compiled without errors.
Thanks for the information.
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
I've been trying to use the Update method of the OleDbDataAdapter to update a MS Access database, but have not had success. I'm updating a DataTable object through several data bound controls and want to update the database using the values in those bound controls by simply clicking a 'Save' button. The Update OleDbDataAdapter method seemed the most appropriate method to use, but it hasn't worked. I don't get an explicit error, but no changes are made to the source database. Would anyone be able to suggest a reason for this? Thanks.
|
|
|
|
|
I assume that you assigned a command object to the UpdateCommand property of the DataAdapter.
If you have done that, then please check if you have access to update the table.
|
|
|
|
|
How would I check if I have access?
|
|
|
|
|
If it's a windows application just try a simple update query and see if you can update it
If it's a web application, try to give ASPNET account proper privileges
|
|
|
|
|
Thanks. Actually, that was not the problem. Basically, I wanted to use a DataGridView to display changes to the underlying data source, while using the data bound text box controls for editing purposes. Unfortunately, the way I set it up, the data table was not getting changed by changing the text box values.
Still, I have encountered another problem, and that is a concurrency violation. What could be the source of the concurrency violation?
|
|
|
|