Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jun 11th, 2008, 2:56 AM   #1
abhisheksainiabhishek
Newbie
 
Join Date: Jun 2008
Posts: 12
Rep Power: 0 abhisheksainiabhishek is on a distinguished road
whitespace remove

If I have a multiline text like..

abcd ef ghi
xyz d e f
d
sjskf s fdf

then how would I be able to remove the spaces (/s+) inside the strings (in middle of the strings).

I thought using doing like...

$string =~ s/\s+/ /g;

would work. but it does not work.

And if above is the way I would end up finally then can I make it like so it would
not alter spaces within <pre> tags like....

#declaring pretags avlyes
my $startPreTag="<pre>";
my $endPreTag="</pre>";


#so the spaces (more than one) will be removed is it is not enclosed by pre tags
$string =~ s/[^$startPreTag]^\s+[^$endPreTag]//;

Please tell me if I am on the right track

None of my appraoches are working. Please advise. Thanks!
abhisheksainiabhishek is offline   Reply With Quote
Old Jun 11th, 2008, 4:53 PM   #2
abhisheksainiabhishek
Newbie
 
Join Date: Jun 2008
Posts: 12
Rep Power: 0 abhisheksainiabhishek is on a distinguished road
Re: whitespace remove

got this working too.

will post the solutions soon.

this thread can be closed now.
abhisheksainiabhishek is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove minimum search word lengths Seif Community Announcements and Feedback 3 May 4th, 2007 12:41 AM
String Substiution. Whitespace? MegaArcon Bash / Shell Scripting 3 Jun 28th, 2006 2:47 PM
Remove with iterator? titaniumdecoy C++ 6 Jun 12th, 2006 8:42 AM
remove(); badbasser98 C++ 16 Nov 10th, 2005 2:24 PM
Remove line from dat file SaturN Python 9 Jun 10th, 2005 2:37 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC