|
Is it because System.timers.timer is not thread-safe, so no data can be retrieved from Clipboard. If it is the case, how can I make the System.timers.timer be thread-safe?
|
|
|
|
|
How do i apply regular expression to find for host name from the text below and it prints out Host name: IT786P20??
Host Name: IT786P20
OS Name: Microsoft Windows XP Professional
|
|
|
|
|
Hi
The question is if you really want to use a regular expression for this. wouldn't a string operation do the job?
someting like
string blah = @"Host Name: IT786P20
OS Name: Microsoft Windows XP Professional"
int colonIndex = blah.IndexOf(":");
string HostName = blah.SubString(colonIndex+1,blah.IndexOf("\r",colonIndex+1)-colonIndex+1).Trim();
Console.WriteLine(HostName);
btw. if you want to work with regular expressions i would recommend you to get expresso it's a free tool with a great regex-Builder and Tester.
here[^]
greets
m@u
|
|
|
|
|
yes i have tried using the regex-builder but i do not know what is the syntax for making a regular expression. my ultimate purpose of using regular expression is becuase i wan to use regular expression to find the text that i want from a text file.
btw is there any software that allows me to type in a word to match from a sample text and gives me the regular expression syntax?
|
|
|
|
|
ah ok.. but you could still use String Operations for it
will that "Machine Name: someName" occur only once in the file?
if so, there's almost no difference between doing it the String Operation - Way or with Regex..
what you mean with syntax?
basically if you want to match a word this already IS a regular Expression
it's no problem to say Regex r = new Regex("Machine Name:");
or in your case, to get the Machine Name "Machine Name: (?<machinename>\w)".
if you use it like that, after applying the regex on your string with Match() you can say
string MachineName = myMatch.Groups["MachineName"].Value;
|
|
|
|
|
i mean syntax like this:
(?sx-m)[^\r\n].*?(? :\.|\?|!)\s)
It gave me an error like this
Error 1 No overload for method 'Regex' takes '1' arguments
Sry to bother u but can u give me a complete code if i were to give u a psuedo code??
|
|
|
|
|
lordbearsg wrote: It gave me an error like this
Error 1 No overload for method 'Regex' takes '1' arguments
hmm.. that's strange.. in .net 1.1 and 2.x it works if you only pass the pattern to the constructor.
what other Parameter does it want?
|
|
|
|
|
/// using System.Text.RegularExpressions;(NameSpace for Regular Exprestion...)
public static bool IsAlphaNumeric(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithSpace(String strToCheck)
{
Regex objAlphaNumericSpacePattern = new Regex(@"^[a-zA-Z0-9\s]*$");
return !objAlphaNumericSpacePattern.IsMatch(strToCheck);
}
public static bool IsNumericWithDot(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[0-9.]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsNumeric(String strToCheck)
{
Regex objNumericPattern = new Regex(@"^[0-9]*$");
return !objNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDot(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9.]");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpace(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpaceHyphen(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,-]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithDotPeriodSpaceHyphenSlash(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9\s.,-/]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAlphaNumericWithSlash(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^[a-zA-Z0-9/]*$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAmount(String strToCheck)
{
Regex objAlphaNumericPattern = new Regex(@"^(\d{1,12}|(\d{1,12}\.{1}\d{1,3}){1})$");
return !objAlphaNumericPattern.IsMatch(strToCheck);
}
public static bool IsAmountBECost(String strToCheck)
{
Regex objAmountPattern = new Regex(@"^(\d{1,8}|(\d{1,8}\.{1}\d{1,3}){1})$");
return !objAmountPattern.IsMatch(strToCheck);
}
<div class="ForumMod">modified on Tuesday, December 18, 2007 4:08:49 AM</div>
|
|
|
|
|
None of these would work, as you are returning not IsMatch, so it will return true if its not matched.
The . in some places need to be escaped too, as it will match anything, if unescaped.
xacc.ideIronScheme a R5RS/R6RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach."
|
|
|
|
|
Below is how i intented on how to make the code work but how do i code it?
Pseudo code
class test
{
public void Test(some arugments??)
{
Read systeminfo.txt;
Search for the word Host Name and show in a message box;
}
}
|
|
|
|
|
Hi, I have to keep all my labels for controls in a resource file to ensure easier translation of the program. How do I set a button's text to what is contained in a resource file, from the form designer? It's easy to set it in code but I'm sure there is a way to set it directly from the designer?
Thanks...
|
|
|
|
|
Set "Localizable" in the property window of the containing form to true.
When you want to translate this form switch the language to non-standard (some specific language) and just change all captions etc. (you can change the positions of the elements if you want).
At the end you will get several resource-folders with the localized versions of your resources - that's it you don't have to provide strings or whatever (of course you will have to use resource-strings for your code-driven output - msgboxes etc.)
|
|
|
|
|
I have created a connectionstring type (SpecialSetting) to store my database connection string. However, I failed to bind property of an SqlConnection object in the form design and error pops up immediately.
Object of type 'Microsoft.VSDesigner.VSDesignerPackage.SerializableConnectionString' cannot be converted to type 'System.String'.
Is there anyway I can fix this whilst the connection string remains in the special setting type and not a string type. Surely, MS made that facility for storing connectionstrings.
Thanks
Using C#, .NET 2.0 development, Windows XP SP2, Visual Studio 2005
|
|
|
|
|
I'd guess that ToString or a property on the class will do it for you.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Everything you may need is here[^]
SkyWalker
|
|
|
|
|
hi all
i have a doubt, that
when i have several "select" queries for different tables, different criterias in same table, SHOULD I USE seperate DATASETS for each query?
pls reply me.
since i did like that, so that the no of datasetsi increased in my proj?
pls suggest?
thanks in adv
kssk
|
|
|
|
|
if you have several queries with the same result you should recycle your DataTable - so no in this case don't use multiple Datasets.
If you query different Tables the answer depends on your taste - I tend to use one DataSet for Tables in the same "category" on the same Database so I never get more then 2-3 datasets in my projects - but sometimes people use one dataset for each table ....
|
|
|
|
|
You shouldn't have to have separate datasets for each query. If you are using the same tables and fields, you can have different Fill, Get methods for each query.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi all,
It’s my very first time posting any problem in the forum like this. I am expecting proper responses from u expert friends.
Problem is that I am in dilemma that which of the technique I should use in the scenario mentioned below.
I have got a server installed in my LAN and I need to send an XML file/string to the client which exists out of my LAN using internet (of course). There may around 500 to 600 client access my server for the data.
Please suggest me which of the techniques:
a. Remoting
b. Web Services
c. Socket
Can solve my problem.
Some constraints are the for each of the techniques as
a. If I go by Remoting, it’s difficult to apply it over internet and not even reliable too as any of the firewall can restrict it.
b. If I go by Web Services I need to have IIS installed on the client’s side which cannot be done for the cost reasons.
c. If I go by sockets again the problem with the firewalls arises.
Please suggest me a proper technique and solution of get ridge of the above mentioned problems associated with each of them.
Note : I am working on C#.Net with the framework 1.1.
Thanks in advance.
|
|
|
|
|
Remoting has a variety of issues, and sockets would just be a pain.
Without knowing about how often you need to send data, I suggest you examine running a web service on _your_ end, and having the clients poll for data.
|
|
|
|
|
Hello Sir,
Thanks for the early response.
But the problem is our architecture does not permit this.
In our case client should not PULL the data rather server should PUSH the data to the client knowing the internet IP of the client.
any solution for this type of case..????
Thanks in advance.
|
|
|
|
|
With any form of "push" mechanic you will need to have correctly configured firewalls. This will be a massive pain. I strongly suggest you take a second look at your requirements and see if "push" is really necessary.
What information are you planning to send that requires the client to know about it immediately? What are the results of the client not finding out for a minute, 10 minutes, or a whole day?
Firewall problems like this should have been considered as part of the initial design.
|
|
|
|
|
Sir,
I am on a project of emergency management, so by this you may be able to understand that the xml information needed to be send to the client is prime importance. I cannot afford delay of any second even.
Thanks.
|
|
|
|
|
Is this information to be consumed by a human or by automated systems? It would be completely feasible to poll for messages every 15 seconds or even less. MSN Messenger will switch to HTTP polling when behind firewalls - and that is usable for "instant" messanging.
If specifications use words like "immediately" I often find that the real requirement is "within a minute". If IIS and firewall issues are a problem then I suggest you client rethink their budget or their requirements.
If you really need realtime communication, then you will need to establish a permanent link to the server from the client. Sockets or remoting will be suitable for this.
|
|
|
|
|
Remoting will be easier than direct sockets. Romoting and direct sockets will have the same issues with configuration of the firewall. Based on the restrictions you have mentioned, remoting over tcp seems like the most workable solution.
Webservices would be the easier way. Remoting over http is similar to webservices, but if you can't run iis on the other side, neither will work.
Another option would be to run an ftp server on the other side but if they are reluctant to install iis then ftp is likely not an option either.
http://blog.darrenstokes.com
|
|
|
|