whitespace

How do I write a Regular Expression to match any non-empty content of an XML element that has no children elements?

I am trying to match elements that have no other children elements, but also have content. No content also includes whitespace and &nbsp; characters. I need to do this in C#. Take this XML for instance: <1> <2><3 /></2> <4> <5>This is match 1</5> </4> <6> </6> <7> &nbsp;&nbsp;&nbsp;&nbsp; ...

jsp:text losing whitespace inside tagx

Trying to use JSPX and running into a strange problem. Text inside jsp:text is supposed to not be subject to whitespace removal, according to the JSP documentation, but when I have a jsp:text element with leading whitespace in the beginning of a tagx file, when used in the jspx views, the leading whitespace disappears. I've done quite ...

Is there a more efficient way of reading a formatted file in C than I have done?

Hi, I need to read in a formatted file that looks something like this. Code: HARK Name: Oscar MRTE: Train etc At the moment my code looks like this. FILE *file; char unneeded[10]; char whitespace[2]; char actual[10]; file = fopen("scannertest.txt","r"); fscanf(file,"%s",unneeded); // this is the identifier and the colon (code:) fs...

How to trim leftmost and rightmost whitespaces of a string using PHP?

What function can I use? ...

Remove whitespace in Python using string.whitespace

Python's string.whitespace is great: >>> string.whitespace '\t\n\x0b\x0c\r ' How do I use this with a string without resorting to manually typing in '\t|\n|... etc for regex? For example, it should be able to turn: "Please \n don't \t hurt \x0b me." into "Please don't hurt me." I'd probably want to keep the single spaces, but it'...

Losing whitespace around escaped symbols in CDATA using Expat XML parser in C++

I'm using XML to send project information between applications. One of the pieces of information is the project description. So I have: <ProjectDescription>Test &amp; spaces around&amp;some &amp; amps!</ProjectDescription> Or: "Test & spaces around&some & amps!" <-- GOOD! When I then use Expat to parse it, my data handler gets ju...

Django template and Python dictionary data structure question

I am trying to present a dictionary from my view.py at the HTML template such as: test = { 'works': True, 'this fails':False } and in the template: This works without a problem: {{ test.works }} But a dictionary key that is having an empty space between words such as 'this fails' doesn't work: {{ test.this fails }} I get this e...

Filtering "whitespace-only" strings in JavaScript

I have a textbox collecting user input in my JS code. I would like to filter junk input, like strings that contain whitespaces only. In C#, I would use the following code: if (inputString.Trim() == "") Console.WriteLine("white junk"); else Console.WriteLine("Valid input"); Do you have any recommendation, how to do the same in JavaSc...

Remove Leading Whitespace from File

My shell has a call to 'fortune' in my .login file, to provide me with a little message of the day. However, some of the fortunes begin with one leading whitespace line, some begin with two, and some don't have any leading whitespace lines at all. This bugs me. I sat down to wrapper fortune with my own shell script, which would remove a...

How to strip insignificant whitespace out of HTML

Hi, I have to compare different versions of HTML pages for formatting and text changes. Unfortunately the guy/company who creates them uses some kind of HTML editor that re-wraps all the HTML every time (and adds tons of whitespace), which makes it hard to diff them. So I am looking for a tool (preferrably a Java library) that can refor...

Problems with WinSCP with whitespaces on ubuntu linux when using SVN Diff

My files are on a remote Ubuntu linux server. When I download the files and edit it in either the WinSCP text client or notepad++, the file whitespaces changes to windows. So when I resave the file back to ubuntu the whitespace are off and SVN Diff thinks every line has changed. FYI, I edit the file by double clicking the file in WinS...

Space bar not working in form fields

I am using a template to build a one page portfolio site. The contact form is acting very strange! I cannot enter space in any of the contact fields. Here is the site: www.cloth2clay.com When you focus in on the message field, it does not allow you to use any spaces. Any ideas? ...

What can I use to substitute &nbsp;&nbsp; in HTML?

&nbsp;&nbsp; is ugly, I think. ...

JSF trimming white spaces

HI, I have an input field in which I want to trim any leading/trailing whitespaces. We are using JSF and binding the input field to a backing bean in the jsp using: <h:inputText id="inputSN" value="#{regBean.inputSN}" maxlength="10"/> My question is that besides validation can this be done in the jsp? I know we can also do this using...

Check if string contains characters & whitespaces, not only whitespaces

Okay this one might be a bit tricky. What would be the best way to check if a string contains only whitespaces? The string is allowed to contain characters combined with whitespaces, but not only whitespaces. ...

XSLT: remove white spaces when transforming to HTML

Hello I have a XML doc that is transformed to HTML but I want the result HTML to be as small as possible. So I must remove all white spaces and line endings. How can I do that? 10x ...

Bash arrays: Need help with white space

I'm trying to create an array in bash from a file with the following sample format: data, data, interesting data, data, more interesting The way I'm populating the arrays: read -r -a DATA1 <<< $(cat $FILE | awk -F, '{ print $1 }') read -r -a DATA2 <<< $(cat $FILE | awk -F, '{ print $2 }') read -r -a DATA3 <<< $(cat $FILE | awk -F, '{...

inline elements, and markup white space rendering issues

Way back in the day, we had to deal with browsers adding white space between elements if in the source markup we also had white space. I thought that issue had all but disappeared but I rant into a situation today where the problem still exists. What's odd is that the problem isn't confined to a particular browser. It shows up the same...

Wordpress Error - Needs a fix

I am moving a Wordpress blog to a new server and have the database in place and the files in place but I am getting an error: Cannot modify header information - headers already sent by (output started at /home/nasepa/public_html/2009/blog/wp-config.php:1) in /home/nasepa/public_html/2009/blog/wp-includes/pluggable.php on line 850 W...

In Javascript or jQuery, how to detect whitespace in beginning of string?

Given the following string: htmlStr1 = " <div>This is a string with whitespace in the beginning</div> "; htmlStr2 = "<div>This is a string with no whitespace in the beginning</div> "; Is there a way to write a function that can detect if this string has a whitespace in the very beginning only? e.g., it should do the following: alert...