whitespace

Regex to match tag contents while simultaneously omitting leading and trailing whitespace

I am trying to write a regex that matches entire contents of a tag, minus any leading or trailing whitespace. Here is a boiled-down example of the input: <tag> text </tag> I want only the following to be matched (note how the whitespace before and after the match has been trimmed): "text" I am currently trying to use...

Matching non-whitespace in Java

I would like to detect strings that have non-whitespace characters in them. Right now I am trying: !Pattern.matches("\\*\\S\\*", city) But it doesn't seem to be working. Does anyone have any suggestions? I know I could trim the string and test to see if it equals the empty string, but I would rather do it this way ...

Removing whitespace-characters, except inside quotation marks in PHP?

Hey I couldn't find any similar question, so I start a new one. I need to remove all whitespace from string, but quotations should stay as they were. I'm building a personal kind of minifier. Here's an example: string to parse: hola hola "pepsi cola" yay output: holahola"pepsi cola"yay Any idea? I'm sure this can be done with rege...

How to minify aspx pages

Hello, I am developing a web-based Pokemon Online game. Since it is online, I would like to optimize it to run as quickly possible. I've installed Firebug and Page Speed suggests minifying my HTML output. I'm also using VS2008, ASP.NET 3.5, AJAX, and IIS 7.5; along with URL-Rewriting. I want to minify my HTML, JavaScript, and CSS. Opti...

Ignoring whitespace in Javascript regular expression patterns?

From my research it looks like Javascript's regular expressions don't have any built-in equivalent to Perl's /x modifier, or .NET's RegexOptions.IgnorePatternWhitespace modifier. These are very useful as they can make a complex regex much easier to read. Firstly, have I missed something and is there a Javascript built-in equivalent to ...

XSL output method text including whitespaces in xsl

Hi, I am creating some xsl to transform my xml into text (which will be csv eventually). I am using VS2008. When I use the editor to create the xsl, the transformed output is indented as per my xsl. However, if I edit the xsl and remove the formatted whitespaces it outputs correctly - but doing it like this is a nightmare to work wit...

remove whitespace and add character in txt

Hello. I have a problem with Matlab code. What I want is that you delete all the blanks in a. Txt (example file below) and that one could add character ||||||||||||| to the end of each line. Example txt: *|V|0|0|0|t|0|1|1|4|11|T4|H01||||||| P|40|0.01|10|1|1|0|40|1|1|1||1|*||0|0|0|| *|A1|A1|A7|A16|F|F|F|F|F|F|F|||||||| *|cod. serv|area...

Table putting words with spaces on different lines

I am trying to make a table in HTML. When I resize the window down to be narrow and the window tries to squash everything to fit inside the window even though it's narrow, it puts the contents of a cell on different lines. I don't want this to happen. E.g.: home about contact us when you narrow down the browser window: home ...

Program to read a code and count the number of lines in it,do not include comments and blank lines in count

I am trying to create a program which, given an input file, returns the count of all the lines of code in the input file, excluding blank lines and comment lines. I have written the following code, however I need help with how to exclude lines containing comments and blank lines. #include<stdio.h> int main() { int count; char ch...

How to trim whitespace between characters

How to remove whitespaces between characters in c#? Trim() can be used to remove the empty spaces at the beginning of the string as well as at the end. For example " C Sharp ".Trim() results "C Sharp". But how to make the string into CSharp? We can remove the space using a for or a for each loop along with a temporary variabl...

Get leading whitespace

Hi, I just wrote this method and I'm wondering if something similar already exists in the framework? It just seems like one of those methods... If not, is there a better way to do it? /// <summary> /// Return the whitespace at the start of a line. /// </summary> /// <param name="trimToLowerTab">Round the number of spaces down to the ne...

How to escape whitespace in a bash alias?

Tried to set some aliases in my .bashrc file. This one... export alias umusic="/Volumes/180 gram/Uncompressed/" ...gets the following error... -bash: cd: /Volumes/180: No such file or directory ...when I try "cd $umusic". I've tried various methods of escaping that whitespace in the directory name, to no avail. (180\ gram, 180%...

How to preserve whitespaces in attributes values when using XDocument?

I process xml which contains tabs ("\t") and line breaks ("\n") in its attributes values. When I parse it using XDocument.Parse(), the tabs and line breaks are converted to spaces, even with the LoadOptions.PreserveWhitespace parameter. How can I get a XDocument with original attributes values? ...

whitespace nowrap css for children but not parent

I have a div with multiple spans inside. The spans contain text that cannot be split over multiple lines so I have set whitespace: nowrap. This does stop the wrapping within each child span correctly but also stop the parent div from wrapping the children so all spans are on a single line that stretches off the page. How do I change thi...

How to remove duplicate white spaces in string using Java?

How to remove duplicate white spaces(including tabs,newlines,spaces,etc...) in a string using Java? ...

Javascript to remove spaces from a textbox value

Hi, I've searched around for this a lot and can't find a specific example of what I'm trying to do. Basically I want to get the value of a textbox, by the name of the text box (not id). Then I want to remove ALL spaces, not just leading or trailing, but spaces in the text too. For example for this html code: <INPUT style="TEXT-ALIGN: r...

cleaning all characters from terminal

void clearscreen ( void ) { char a = 'a' ; fflush ( stdout ); do{ a = getc( stdin ) ; if ( isspace ( (int ) a ) ) { getc ( stdin ); } }while ( a != EOF ); } I want write functi...

getline check if line is whitespace

Is there an easy way to check if a line is empty. So i want to check if it contains any white space such as \r\n\t and spaces. Thanks ...

Regular expression to replace line feeds with a space only if the break is not in the contents of an HTML attribute

I'm trying to write a regular expression that replaces line feeds between certain areas of a text file, but only on plain text content (i.e. excludes text inside HTML attribute contents, like href) but not having much luck past the first part. Example input: AUTHOR: Me DATE: Now CONTENT: This is an example. This is another example. <a ...

Whitespace and indentation in F#

I'm just learning about F# and plan to use it for my next project. One thing I find immediately confusing is the lack of support for tab characters in .fs files. I love how indentation is used to show scope/hierarchy, but using spaces just seems so antiquated. Do I have to press backspace four times just to get back to the parent block? ...