Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm creating a mini code generator in c#. Say i have a string
string val= "i=0;i<5;i++";
As I'm taking complete structure of for loop as a string. How to find the syntax error if user gives wrong input? For example terminator missing or other logical errors? Should i have to use regex?
No i don't think regex is good option because you have to take many things into consideration.
but i would suggest try this instead
https://support.microsoft.com/en-us/help/304655/how-to-programmatically-compile-code-using-c-compiler
using c# compiler itself to do work for you.
but keep that in mind this will ask for whole c# code so you may have to do some string manipulation to get around that.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have similar requirements to those mentioned in this question: compare two phone numbers
I want to compare phone numbers which are in different formats. For example, +467856753421 = 07856753421 = 7856753421.
Is it possible to do it without using the google library recommended in the linked question?
You could try to write a method that sanitises the input string to a standard format, and compare them, but phone numbers have so many different formats that something is bound to slip through the gaps, this is an area where I would strongly recommend a well-tested library that someone else has spent all that time writing for you.
Try this regex:
(^[+]\d{2}|^0*|^00\d\d)(\d*)
The first capture group is your prefix. The second is your number.
(This might need some adjustment if you have US prefixes which are +1 and 001.)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Is there any solution to parse a java manifest (manifest.mf) file in C#?
I need to get values from it.
Thank you very much!
I doubt that there's a C# Specific library for this, but this question (Use of the MANIFEST.MF file in Java) has a great overview of the file, what it's for, and a lot of other helpful information.
That being said, the quick and dirty way (in my opinion) for how to do this would be split every line by a colon, the first value in the array is the header name, and all other values after that, would be the value. (just in case your value has a colon in it, I'm unsure if that's allowed by the spec or not but, but I'd assume so.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I came across writing Regular Expressions against user input in a C# console application, here are a couple of questions:
When a RegEx becomes pretty long like below, is it smart to keep where it is in the code? Or put it with my other constants in their own class? Or even smarter to just not use it and do it some other way?
Regex regEx = new Regex(#"\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*([,;]\s*\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*)*");
How does RegEx affect the behavior/load of my application and what more do I have to consider when using RegEx?
You should definitely use Regular Expressions. You should however look out for the performance implications if used incorrectly. If you are using it frequently, you should look at using Compiled Regular Expressions.
For further reading on the performance & best practices there is a nice MSDN article http://blogs.msdn.com/b/bclteam/archive/2010/06/25/optimizing-regular-expression-performance-part-i-working-with-the-regex-class-and-regex-objects.aspx
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
For my job i have to make many small projects that require to send different mails and set up some html. I usually make these forms in Winforms. Now at this moment whenever i need to fill my html I take the string replace some values and have functions that write hardcoded table rows.
To make my job a little easier I was wondering if it was possible to import the razor engine(not sure if it's the right word choice) in my winforms project and simply pass a model to a CSHTML file which returns me the HTML in a string so i can mail it to coworkers.
If this is possible, instructions on how to do it are welcome.
Kind Regards Roxas
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to ask for any sample queries that used to retrieve multiple field from table to do maths calculation?
Another thing is, should I do the calculation in the rdlc report by using Expression, or using queries?
I don't understand your first question. But I will gladly answer your second one from my point of view:
I try to do most calculations on the Database. Because thats what a database should do and complex expressions are not very good and easy to maintain.
You will have to use Expressions on top of that alle the time (in complex reports) so I prefer to do all on the Database that can be done there.
But only as long as your SQL Queries are maintainable and fast.