Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove spaces within a string

Status
Not open for further replies.

jayfox

Programmer
Dec 19, 2002
29
0
0
US
I have some text data with htmls tags in it. I want to remove the spaces with in the tags
Ex.

<br><br> This is a test <font -1 type>
result:
<br><br> This is a test <font-1type>

I only want to remove the spaces with in the brackets
and not all the positions are the same in each cell
thanks for the help
 
Try this:

UPDATE MYTABLE
SET MYFIELD = REPLACE(MYFIELD,' ','')

DBomrrsm
 
Sorry that wont do - just realised you only want to remove the spaces from within the <>.

See this thread for the answer thread183-887418

DBomrrsm
 
Hi Jayfox.

How about this:
Code:
Dim tmp,i
If Instr(1,myString"<") Then
  tmp=split(myString," ")
  myString=""
  for i=0 to ubound(tmp)
    myString=myString & tmp(i)
  next
end if

[pipe]
Cheers,
Andy

[blue]The last voice we will hear before the world explodes will be that of an expert saying:
"This is technically impossible!" - Sir Peter Ustinov[/blue]
HP:
 
MakeItSo,

This is the SQL Server forum, not VB or Access.

jayfox,

You'll need to write a function that accepts a string and returns the correct output. It should look for any "<" characters, then find the next ">" or the end of the string and replace spaces. Then, continue searching after the ">" for a next occurrence of "<".

-------------------------------------
A sacrifice is harder when no one knows you've made it.
 
You are right. But since there are HTML-Tags with spaces in a db, I assumed, they might be inserted via asp - and thus with vbscript. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top