reading in .dat file data into an array - keeping whitespaces Programming Software Development by tphuynh …+", RegexOptions.None);" so the string will also keep whitespaces? For example, in the .dat file you have: Hello Word… Test1 Test2 Test3 If you noticed, I have whitespaces between each words, I want to keep that. so string… Perl Whitespaces Programming Software Development by bigfoot_80906 How does Perl count the number of whitespaces in a file? New to python, need whitespaces in output Programming Software Development by Steko To process my data files I need whitespaces between all characters in a string, to be written to a text file. Is there a simple Pythonfunction to solve this? Putting Whitespaces and newlines Programming Software Development by gallantmon1 Does anyone know how to put a whitespace or a newline in a .txt file??? By this I mean, I have this long string, and I have to put whitespaces and new lines to make it understandable. To summarize, I just want to know what functions will be effective to do this XSLT preserve whitespaces Programming Software Development by mahendra dubey …> </xsl:stylesheet> [/code] but i lost the whitespaces in this case if I add the " xml:space… validation of whitespaces Programming Software Development by andyhunter … data is entered. I have a problem with matching for whitespaces using \s as it doesnt work. many thanks do{ /*if… Read from text file/deleting multiple whitespaces Programming Software Development by code_r … to read from a text file and have any multiple whitespaces between characters become one whitespace. If this how I do… Remove all whitespaces......except actual spaces! Programming Software Development by riahc3 Hey I want to remove all strange whitespaces (such as Alt+0160) except the actual space, as in spacebar. How can I do this? Re: Finding whitespaces Programming Software Development by ~s.o.s~ … are accepting user input which is causing it to trim whitespaces. One minor point; instead of [ICODE]passCh == ' '[/ICODE], consider using… Re: Perl Whitespaces Programming Software Development by Comatose I don't understand exactly what you mean. I can tell you that spaces, tabs, and newline characters qualify as white spaces..... if you would like sample code, that tells you how to count the number of white spaces.... then that's a different story. Re: Perl Whitespaces Programming Software Development by bigfoot_80906 I am reading a file and trying to make a string based on the number of spaces that precedes the character that will go in the string. Does perl count each space as one character, or does it even count them at all? Re: Perl Whitespaces Programming Software Development by Comatose Here is some code for you to count the number of "white spaces" in a file at the end of the string... the sub (function) classifies white spaces as space, tab, and newline.... you can modify the source accordingly, should it only be spaces, or only be tabs, or both... or any combo.... [CODE] $file = $ARGV[0]; if ($file eq ""… Re: Perl Whitespaces Programming Software Development by Comatose Yes, Perl Counts Spaces as 1 character...and you can modify the above sub to count from the begining of the string, and loop until it finds a normal character. The one above finds trailing white spaces.... so, it starts from the very right of the string, and loops until there are no more tabs, spaces, or newline characters trailing "normal … Re: Perl Whitespaces Programming Software Development by bigfoot_80906 Thanks a lot! That helps more than you can know! Re: New to python, need whitespaces in output Programming Software Development by mawe Hi! Well, Python doesn't have one simple function for this, but you can combine 2 simple functions, [i]list()[/i] and [i]join()[/i] :) [code]s = "hello" # convert the string to a list of characters lst = list(s) # lst now looks like this: ['h', 'e', 'l', 'l', 'o'] # now combine the list-elements to a string with a whitespace … Re: New to python, need whitespaces in output Programming Software Development by Steko Many thankx Re: Putting Whitespaces and newlines Programming Software Development by Ancient Dragon Need an example. you want to change "WethePeopleoftheUnitedStates" to this: "We the People of the United States" ? If the text is in a file then you will have to completly rewrite the file. First open the original file for reading, then another file for writing. In a loop read a line, modify it in memory as desired, then … Re: Putting Whitespaces and newlines Programming Software Development by gallantmon1 Sorry about that, but yes, that is my problem. Re: Putting Whitespaces and newlines Programming Software Development by Ancient Dragon [QUOTE=gallantmon1;513966]Sorry about that, but yes, that is my problem.[/QUOTE] If this is schoolwork then your teacher should tell you how to do it. Otherwise, its nearly impossible for a program to check a string and add spaces where necessary to make it understandable to a human reader. You need to get more information from whoever gave … Re: Putting Whitespaces and newlines Programming Software Development by gallantmon1 The input is this "mova,badda,b" and I have to turn it into this: mov a, b add a, b The program doesn't have to be flexible, because there is a given string. My problem is as you said how can I know where to put it Re: Putting Whitespaces and newlines Programming Software Development by Ancient Dragon that should be fairly simple. First find the comma and back up one character. That is where you insert the space. Add another space immediately after the command, and a line feed one character beyone that. Do it with two string arrays -- the first is the original string and the second is the altered string. I would write it for you, but I … Re: Putting Whitespaces and newlines Programming Software Development by gallantmon1 Could you explain the two string arrays further, I'm not that good when it comes to arays, but thanks for the help. At least now I have an idea on how to do it. Re: Putting Whitespaces and newlines Programming Software Development by Ancient Dragon >>Could you explain the two string arrays further You can't use the original string array to insert the spaces for a couple reasons [list] [*] the array may not be large enough to hold the additional characters. [*] the array may be a literal and stored in read-only memory, any attempt to change it would probably crash the program. [/… Re: Putting Whitespaces and newlines Programming Software Development by gallantmon1 Ok, thanks for the help. I finally get what your saying. Re: validation of whitespaces Programming Software Development by andyhunter can any one help please Re: validation of whitespaces Programming Software Development by hanvyj salesPersonName.matches("^[^a-z,^A-Z,\\s]$") failes for everything (eg "John"), I dont know much about regex though. Re: validation of whitespaces Programming Software Development by andyhunter [QUOTE=hanvyj;1435046]salesPersonName.matches("^[^a-z,^A-Z,\\s]$") failes for everything (eg "John"), I dont know much about regex though.[/QUOTE] thanks for your help, i found a page on here that had bits and pieces, i was only validating one character instead of multicharacters my regular expression required a + ([]+)… Re: validation of whitespaces Programming Software Development by hanvyj [CODE]public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.println("type your name"); String name = ""; boolean accepted = false; while (!accepted) { name = in.nextLine(); Pattern p = Pattern.… Re: Read from text file/deleting multiple whitespaces Programming Software Development by WaltP So what doesn't work? You need to give us informations if you need help. Re: Read from text file/deleting multiple whitespaces Programming Software Development by Gonbe > So what doesn't work? You need to give us informations if you need help. > how can I do it reading from the file? It's clear what he wants to achieve. Going by his code sample it's also clear what isn't working. But I know you have a reading disability so I'll not bully you with it. ;) @izic The problem you're having is that you made a …