mahdoumMar 4, 2007Post #1 Sunday, March 4, 2007 5:36 PM Whats the quickes way to strip all whitespace from the beginning and the end of the string? Here's an example Before: " This is a test string " After: "This is a test string"
mirMar 4, 2007Post #2 Sunday, March 4, 2007 6:11 PM Trim for both beginin & end there is also ltrim and rtrim for right & lefts :)
mahdoumMar 4, 2007Post #3 Sunday, March 4, 2007 7:24 PM lol nice, can't believe I've never heard of the trim function
LLebaneseChipheadMar 6, 2007Post #4 Tuesday, March 6, 2007 5:14 PM Hey, I would use the function Mir had pointed U at" U better" , but if U feel like programing in .cpp, here u go the code in .cpp: //Delete all whitespace, excluding spaces following 1st significant //character i=0; j=0; while (line!=CNULL && i<MAX_LINE_LENGTH) { if ( !isspace(line) || (line==' '&& j>0)) { line[j] = line; j++; } i++; } line[j] = CNULL; } that ismy two cents :)
samerMar 6, 2007Post #5 Tuesday, March 6, 2007 7:39 PM in PHP, you can use some useful built-in functions: trim (left and right) ltrim (left only) rtrim (right only) check the URIs for usage information :) And here's the regex pattern to do it: /^\s+|\s+$/g,"" enjoy!
mahdoum Whats the quickes way to strip all whitespace from the beginning and the end of the string? Here's an example Before: " This is a test string " After: "This is a test string"
LebaneseChiphead Hey, I would use the function Mir had pointed U at" U better" , but if U feel like programing in .cpp, here u go the code in .cpp: //Delete all whitespace, excluding spaces following 1st significant //character i=0; j=0; while (line!=CNULL && i<MAX_LINE_LENGTH) { if ( !isspace(line) || (line==' '&& j>0)) { line[j] = line; j++; } i++; } line[j] = CNULL; } that ismy two cents :)
samer in PHP, you can use some useful built-in functions: trim (left and right) ltrim (left only) rtrim (right only) check the URIs for usage information :) And here's the regex pattern to do it: /^\s+|\s+$/g,"" enjoy!