|
Aheum....
Let's say it always comes as a surprise (a shock?) to see how inexperienced an inquiring developer could be.
But well, I guess we all have to start somewhere, someday, ...
Myself, I remember when I was young... mouahahaha
|
|
|
|
|
You got me. But at least I know how to do it now....Sometimes I go right to posting a message instead of spending some time with MSDN help.....
|
|
|
|
|
SkunkedWorks wrote:
Sometimes I go right to posting a message instead of spending some time with MSDN help...
Believe me, I've been working with programming for more than 20 years, now: the time you spend with MSDN teaches you a lot more than you notice. On online forums, people will teach you exactly what you asked for, and often in MSDN, you'll find a lot of other interesting things while looking for an answer.
I see dead pixels
Yes, even I am blogging now!
|
|
|
|
|
|
<br />
int counter = 0; <br />
ArrayList Numbers = new ArrayList(); <br />
Regex regex = new Regex(@"(.+);(.+);(.+)");
Match matchit = regex.Match("Gerald; 0650123456; Sabine; Spech; 06761233333"); <br />
<br />
for (int i = 0; i < matchit.Groups.Count; i++) <br />
{ <br />
Numbers.Add(matchit.Groups[i].Value); <br />
MessageBox.Show(Numbers[i].ToString().Trim()); <br />
}<br />
hi the regex here don't work...i want to make it, that it works for:
"Gerald; 0650123456; Sabine; Spech; 06761233333"
result:
Numbers[0] = Gerald;
Numbers[1] = 0650123456;
Numbers[2] = Sabine;
Numbers[3] = Spech;
Numbers[4] = 06761233333;
and for:
"Gerald; 0650123456; Mike"
result:
Numbers[0] = Gerald;
Numbers[1] = 0650123456;
Numbers[2] = Mike;
the regex have to be independent from the length of the input string....
cu
|
|
|
|
|
Try to use the following regex expression:
Regex regex = new Regex(@"[\w\d ]+;[\w\d ]+;[\w\d ]+");
the expression stands for:
at least one word, digit or space followed by semicolon
and
at least one word, digit or space followed by semicolon
and
at least one word, digit or space.
Let me know if it's ok
Uri
|
|
|
|
|
|
Hi,
Maybe I didn't understand the requirements of your regex, because the regex I have provided returns a valid value for exectly 3 words or digit sets seperated by a comma.
Could you provide me with more info about the results you are expecting to have ?
|
|
|
|
|
the regex should not only works for 3 words! for 9 words too...
looks like that:
"Gerald; 067612345; Sabine"
or
"Gerald; 067612345; Sabine; Mark; 065012233"
than i want to have the names or numbers in an array:
array[0] = Gerald
array[1] = 067612345
array[2] = Sabine
array[3] = Mark
array[4] = 065012233
cu
|
|
|
|
|
Hi,
* use the following expr. @"(?>\w|\d)+;?)"
* use the Matches method and not the Match method as follows:
ArrayList Numbers = new ArrayList(); <br />
Regex regex = new Regex(@"(?>\w|\d)+;?");
MatchCollection collection = regex.Matches("Gerald; 0650123456; Sabine; Spech; 06761233333");<br />
foreach(Match m in collection)<br />
{<br />
Console.WriteLine("**" + m.Value);<br />
}
-- modified at 12:12 Saturday 27th August, 2005
|
|
|
|
|
hi, looks good!
but the output is:
Gerald;
0650123456;
Sabine;
Spech;
06761233333
i dont need the ;
i can use substr but can i solve that with regex only?
cu
|
|
|
|
|
Yes
Just remove the ;? from the regex expression i.e. use the following expression: "(?>\w|\d)+" .
Hope it helps...
|
|
|
|
|
hi, perfect, thats what i want where can i learn regex? i am not that profi
here the code now:
<br />
int counter = 0; <br />
ArrayList Numbers = new ArrayList(); <br />
MatchCollection matchCollectionNamen; <br />
Regex regexNamen = new Regex(@"(?>\w|\d)+");<br />
matchCollectionNamen = regexNamen.Matches("Gerald; 0676123456; 06503333543; Sabine");<br />
<br />
foreach (Match m in matchCollectionNamen) <br />
{ <br />
Numbers.Add(m.Value); <br />
MessageBox.Show(Numbers[counter].ToString());<br />
counter++; <br />
}<br />
do you have an idea how i can test for the first 4 digits when a number is recognized?
only 0676, 0650, 0699, 0664 should be allowed for the first 4 digits...
a second regex expression is needed?
cu
|
|
|
|
|
Lets see if you guys can figure this one out.
I have WriteProcessMemory 'ed a path name of a .DLL into a remote process after VAlloc 'ing it.
<b>
Simple so far. Just a pathname in a remote process.</b>
Now I want to create a remote thread in that process using CreateRemoteThread, however, and this is the tricky part, I want to pass the address of LoadLibrary as CreateRemoteThread's starting address. Now I know I could just plug in the real address of my LoadLibrary, however I know this address changes from not only OS to OS version but from DLL version to DLL version. This is so that once the thread is created is starts directly at LoadLibrary, loading the path'ed DLL, and exits the thread when LoadLibrary is finished.
CreateRemoteThread(hProcess, 0, 0, <Address of LoadLibrary>, szRemotePath, 0, &dwTID);
Is there anyway to do this?
I know in C++ I would simply just use &LoadLibrary, however this does not work in C#. Even after PInvocation of LoadLibrary it will not do so. AddressOf doesn't work either.
Thank you in advance, and you'll get another after your answer!
-- modified at 18:32 Friday 26th August, 2005
|
|
|
|
|
Total guess: you could call LoadLibrary on kernel32.dll to get kernel32's HMODULE, then call GetProcAddress to get the address of LoadLibrary. Then you can pass that address to CreateRemoteThread.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Agreed. Actually I found a sample in a blog exactly doing this.
private void foo(IntPtr handle)
{
SecurityAttributes a = new SecurityAttributes();
hThread= CreateRemoteThread (handle, ref a , 0,
GetProcAddress(GetModuleHandle("KERNEL32.DLL"),"ExitProcess") ,
54,0,ref threadid);
//blah blah
}
[DllImport("kernel32.dll")]
static extern IntPtr CreateRemoteThread(
IntPtr hProcess,
ref SecurityAttributes lpThreadAttributes,
int dwStackSize,
IntPtr lpStartAddress,
uint lpParameter,
int dwCreationFlags,
ref int lpThreadId
);
struct SecurityAttributes
{
int nLength;
uint lpSecurityDescriptor;
bool bInheritHandle;
}
[DllImport("kernel32.dll")]
static extern IntPtr GetProcAddress (IntPtr hModule, string lpProcName);
[DllImport("kernel32.dll")]
static extern IntPtr GetModuleHandle (string lpModuleName);
Live Life King Size
Alomgir Miah
|
|
|
|
|
Folks this is a simple amost silly question, but still i would like to ask:
I would like to imitate form close event identical to when you presses X to close, when I click on a button for close a form. I basically want to catch all exception in from control when the button clicked.
Sincerely,
Max Pastchenko
|
|
|
|
|
Can you try explaining it again?
/\ |_ E X E GG
|
|
|
|
|
well, i thought this was rather a simple question.... hmmm
Well here is what I tried, on the button click event, I tried calling form closing event where say textbox validation occured, but when exception is thrown, It does not get that piece of code.
Sincerely,
Max Pastchenko
|
|
|
|
|
Here we go again,
Lets say i use this.close for close a form as this point ( when i press on a command that closes my form). I want to know an alternative way of doing so. This is because form closing event is not being called. It does get called when I press X of the form.
What i want to acoomplish is trap any control value errors on form close (is text field empty or not when form closes). Does this help?
Sincerely,
Max Pastchenko
|
|
|
|
|
Better validation check to simply validate values on text cahnged event
Sincerely,
Max Pastchenko
|
|
|
|
|
Hi,
I have a procedure in Form_A which changes the form text and the label caption on the same form and display a message. The procedure is:
public void yahaa()
{
this.Text = "TEST";
lblName.Text = "TEST";
MessageBox.Show("Yahaa!!", "STOP!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
I am calling this procedure from Form_B
but I am just getting the message displayed without changing the form text and label caption
first, I want to ask wehther what i'm doing is correct because I want to add some database action in the same proceure.
then, if it is correct.. why the form text and label caption are not changed..
Many Thanks
Jassim Rahma
|
|
|
|
|
jrahma wrote:
I have a procedure
The pedant in me wishes to remind you that this is a "method" not a procedure.
jrahma wrote:
why the form text and label caption are not changed..
Are you sure? The label and form text should change on Form_A. Are you expecting it to change on Form_B?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
thanks for the reminder
no.. i am not expecting it to change Form_B but it's not even changing Form_A. I am only getting the messagebox without the form text and label caption & i don't know why!!
|
|
|
|
|
How are you exposing the method to Form B and how are you calling it?
Code snippets help alot!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|