Avatar of sharingsunshine
sharingsunshine
Flag for United States of America asked on

Remove   Using Dreamweaver CC

I have an editor that is putting in many  's in the source code it is creating.  I have been unable to stop the insertion of the strings but I do need them removed.

Here is an example
<tr><td align="left" style="color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; padding: 0px 0px 0px 10px; text-align: left;"><a href="http://www.theherbsplace.com/onsale" style="color: #5583c7;" target="_blank"><img alt="Nature's Sunshine" src="http://image.exct.net/lib/ff2c1c757166/i/4/096bf034-0.jpg" style="border: 0px; display: block;" /></a></td><td align="right" style="color: #6e6f74; font-family: Arial, Helvetica, sans-serif; font-size: 14px; padding: 0px;" valign="middle">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <table border="0" cellpadding="0" cellspacing="0" style="border-spacing: 0px;"><tbody>

Open in new window


Please help me with a regex that will remove these extra strings.

I have tried many options using RegexBuddy but I can't seem to get it to match correctly.
(.+?)([(&nbsp;)]+)(.+?)

Open in new window

replacing with $1 $3.

This is the output I get
<tr><td alig ="left"  tyle="color: #6e6f74  fo t-family: Arial, Helvetica,  an -serif  fo t- ize: 14 x;  addi g: 0 x 0 x 0 x 10 x; text-alig : left "><a href="htt ://www.theher lace.com/o ale"  tyle="color: #5583c7 " target="_ la k"><img alt="Nature'  Su hi e"  rc="htt ://image.exct. et/li /ff2c1c757166/i/4/096 f034-0.j g"  tyle=" order: 0 x; di lay:  lock " /></a></td><td alig ="right"  tyle="color: #6e6f74  fo t-family: Arial, Helvetica,  an -serif  fo t- ize: 14 x;  addi g: 0 x;" valig ="middle">
&  
&  
&  
&  
&  <ta le  order="0" cell addi g="0" cell aci g="0"  tyle=" order- aci g: 0 x;"><t ody>

Open in new window


It seems to be ignoring I need the whole string removed but is in turn removing the single characters too.

Thanks,
Regular ExpressionsAdobe Dreamweaver

Avatar of undefined
Last Comment
sharingsunshine

8/22/2022 - Mon
Ryan Chong

try create your website as a project in your DW, and then do a Find and Replace for the entire site.... (find &nbsp and replace it with blank)

Find and replace text, tags, and attributes
https://helpx.adobe.com/dreamweaver/using/find-replace-text.html
sharingsunshine

ASKER
Thanks for getting back to me.  The only problem is that these encoded spaces don't show on Dreamweaver but they do when I transfer them to Blogger.  So I need to remove the white space that translates to &nbsp; outside of dreamweaver.

Here is a screenshot of what it looks like before I paste it into blogger.

https://gyazo.com/112d345ce98216d7ded15eb2798c93b9
Ryan Chong

why bother about the "white space" in HTML? it will not affect how HTML is being generated
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
sharingsunshine

ASKER
I know that but when I take the source code and post it to blogger I get all of the extra &nbsp;'s that skew the way the content is presented.  If I can get a regex to remove it then the  content won't be skewed on blogger.
Ryan Chong

what about if you paste the content into a Notepad before copy it again from Notepad to blogger, will the blogger still adding the white spaces?

for the blogger, can you paste the content in HTML view?
Shaun Vermaak

⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
sharingsunshine

ASKER
I appreciate all of the suggestions but as I asked in the beginning.  I really want a regex to do the job.  Not only for this problem but for some others not specified.
Shaun Vermaak

If you want to keep the first you can use this and delete all matches
(?<=&nbsp\;)(&nbsp\;| |\n|\r)+

Open in new window

Here is demo
https://regex101.com/r/LofGmX/1
regex2.png
sharingsunshine

ASKER
I am getting this message
https://gyazo.com/618ae12d905eaf63677a84166b23774a 

I have tried this in Dreamweaver CC and Brackets both.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Shaun Vermaak

Perhaps Dreamweaver does not support all RegEx syntaxes
sharingsunshine

ASKER
You are probably correct but I need it to work on Dreamweaver.  So can you build one using its capabilities?
NerdsOfTech

try without positive look behind:
((&nbsp\;)+(\s)*?)+

Open in new window

\s matches any whitespace character (equal to [\r\n\t\f\v ])
https://regex101.com/r/LofGmX/2

http://www.adobe.com/devnet/archive/dreamweaver/articles/regular_expressions_pt1.html
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Shaun Vermaak

That would remove all &nbsp;, not true?
NerdsOfTech

It would remove all &nbsp;'s AND whitespace if and only if preceded by &nbsp;

I created an even better RegEx for Dreamweaver CC (tested in 2018 version):

((\s)*?(&nbsp\;)+(\s)*?)+

Open in new window


It removes whitespace which proceeds and succeeds (if any) &nbsp;'s and the &nbsp;'s
Shaun Vermaak

I assume OP wants to keep one so just replace with &nbsp;?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
NerdsOfTech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Shaun Vermaak

extra &nbsp;
NerdsOfTech

In this case, greedy \s matches are better, final draft of RegEx for DW CC:

((\s)*(&nbsp\;)+(\s)*)+

Open in new window


greedy \s is better
and @Shaun please re-read the OP comment; OP is saying both whitespace (and extra &nbsp;'s, as a result of blogger's encoding) are an issue and that they should be eliminated.
Shaun Vermaak

Please reread my comments especially #a42418762, I know about the white-space and line-breaks.

My question is... Why is it okay to remove all whitespace (&nbsp; etc.)  when it repeats but leave it when there is one?
Either one needs to stay when there is a repeat -OR- all needs to be removed irrespective of repeats
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
sharingsunshine

ASKER
thanks
sharingsunshine

ASKER
Why is it okay to remove all whitespace (&nbsp; etc.)  when it repeats but leave it when there is one?

Shaun,

If I have one whitespace it is because I put it there.  If I need repeats I use CSS.