It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I have to write an ASCII and have the schemah, each row should be 128 characters, I took string and string and attached so that each field received his position, the test was exactly 128 characters, but in edit.com it's not the right place, I asked how to make the file ascii code? And is there a way to write each string a certain position?
I can not upload the schamah is not in English, also, it i do not speak English and sorry for the mistakes.
thanks in advance
You most likely don't write your file with ASCII encoding - try this:
string myRow =string.Join("", Enumerable.Repeat("A", 128));
string[] rows = new string[] { myRow, myRow };
File.WriteAllLines(#"test.txt", rows, Encoding.ASCII);
This produces a text file where each line is encoded in ASCII (one byte per character) and rows are separated by \r\n characters. The sample produces a file with a size of 260 bytes, 128 bytes for each row plus 2x the two characters for line seperation.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I need to match a filenames in the filelist with database rows by Regex.
File names are numbers with leading zeros
Database values are numbers without leading zeros
Sample file list:
0001.jpg
0002.bmp
...
0012.bmp
0013.bmp
0014.jpg
...
1012.jpg
...
1015.jpg
...
I use C#. And I need to match each file name with each row in the database.
You can use this regex
^0+\d+[.](jpg|bmp|jpeg|exe)
OR
^0+\d+[.]\S+
I'm somewhat reluctant to answer, but in order to match those file names (which is what I presume you are trying to do) you should try: \d{4}\.(jpg|bmp)
EDIT:
Since you are so liberal with your -1's..
Regex isn't really the correct technology to use to solve your coding problem, regex is used to find a string that matches a pattern.
The problem you appear to describe is that you have a poorly typed file system with unnecessarily added 0's and want to convert (for example) a 4 to 0004 and not care about what file extension you have.
The "best solution" to your problem is to fix the numbering system of your files or simply to add the leading 0's in c#, not to use a technology that is designed to do something completely different.
Enjoy your -6.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I am new to learning Regex and I am struggling with this basic issue. I want to make sure a string is in a format like: 2000/2001 or 2010/2011.
I tried something like: ^[2000-2900]./.[2000-2900]$ but I know this is wrong!
This would be the very basic:
^\d{4}\/\d{4}$
From the beginning of the string, check if it has 4 digits followed by a "/" (escaped with "\") and another 4 digits to the end of the string.
If you searching for where the entire string must match then:
^\d{4}/\d{4}$
If you are searching for a sub string of a larger string then:
\d{4}/\d{4}
And if you using in C# then remember to wrap it up in a verbatim string like so:
#"^\d{4}/\d{4}$"
#"\d{4}/\d{4}"
I noticed that others are escaping the forward slash but I don't think is necessary but doesn't do any harm if you do.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to format an integer so that it appears first with the 1000's separator (,), but after that with 100's separator (,)
Input:123456789
Output: 12,34,56,789
You can create a NumberFormatInfo that has a NumberGroupSizes array that gives you that format:
NumberFormatInfo info = new NumberFormatInfo();
info.NumberGroupSizes = new int[]{3,2};
Console.WriteLine(123456789.ToString("#,#", info));
Output:
12,34,56,789
This can help you out:
1. the currency depending on the culture,
2. the currency in your wanted format without any cash mark
int iValue = 2879068;
string sValue1 = String.Format("{0:C}", iValue);
string sValue2 = String.Format("{0:#,#.}", iValue);
but in case if you want to have some cash mark, simply do:
{0:$#,#.}//or
{0:#,#.€}
Hope it helps,
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
In the case that there were two text files:
FileA.txt
test
1234
testing
FileB.txt
test
5667
pond
and all occurrences in FileA.txt would be removed from FileB.txt, being output into FileC.txt
So FileC.txt would read:
5667
pond
File.WriteAllLines("FileC.txt",
File.ReadAllLines("FileB.txt").Except(File.ReadAllLines("FileA.txt")));
string fileA, fileB, fileC;
var result = File.ReadAllLines(fileB).Except(File.ReadAllLines(fileA));
File.WriteAllLines(fileC, result);
I'm not sure how your text files are formatted, but you can use StreamReader to load and read through the lines of the text. First, do that to A, add each line to an array, and then filter through the array for each line of B to see if there is a match. If so, remove that line from B before creating C with StreamWriter.
Read about streamreader here. Read about streamwriter here.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
explain the rangevalidator control,is it take string also? explain thank you
It supports
Currency
Date
Double
Integer
String
For comparing strings better to use Regularexpressionvalidator instead of Rangevalidator.
In case of type string for the range validator it will only check the character by character, not the length of the string.
Yes, it does support string range validation.
Please look at the documentation before asking question.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.rangevalidator.aspx
MSDN:
The RangeValidator control allows you to check whether a user's entry is between a specified upper and a specified lower boundary. You can check ranges within pairs of numbers, alphabetic characters, and dates. Boundaries are expressed as constants.