Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6029689
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:55:25+00:00 2026-05-23T04:55:25+00:00

I have a strings stored in my database formatted as html, and users can

  • 0

I have a strings stored in my database formatted as html, and users can change the font size. That’s fine, but I need to make a report and the font sizes all need to be the same. So, if I have the following html, I want to modify it to have a font size of 10:

<HTML><BODY><DIV STYLE="text-align:Left;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:11;color:#000000;"><DIV><DIV><P><SPAN>This is my text to display.</SPAN></P></DIV></DIV></DIV></BODY></HTML>

I have a user defined function, but apparently, I can’t use wildcards in a REPLACE, so it doesn’t actually do anything:

ALTER FUNCTION [dbo].[udf_SetFont]
(@HTMLText VARCHAR(MAX))
RETURNS VARCHAR(MAX)
AS
BEGIN
RETURN REPLACE (@HTMLText, 'font-size:%;', 'font-size:10;')
END

(Of course, it would be even better if I sent the font size as a parameter, so I could change it to whatever.)

How do I modify this to change any string so the font size is 10?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:55:26+00:00Added an answer on May 23, 2026 at 4:55 am

    This appears to work, although I’ve only tried it on one string (which has the font set in 2 places). I started with code that strips ALL html and modified it to only look for and change ‘font-size:*’. I suspected there would be issues if the font size is 9 or less (1 character) and I’m changing it to 10 (2 chars), but it seems to work for that too.

    ALTER FUNCTION [dbo].[udf_ChangeFont]
    (@HTMLText VARCHAR(MAX), @FontSize VARCHAR(2))
    RETURNS VARCHAR(MAX)
    AS
    BEGIN
    DECLARE @Start INT
    DECLARE @End INT
    DECLARE @Length INT
    SET @Start = CHARINDEX('font-size:',@HTMLText)
    SET @End = CHARINDEX(';',@HTMLText,CHARINDEX('font-size:',@HTMLText))
    SET @Length = (@End - @Start) + 1
    
    WHILE @Start > 0
    AND @End > 0
    AND @Length > 0
    BEGIN
    SET @HTMLText = STUFF(@HTMLText,@Start,@Length,'font-size:' + @FontSize + ';')
    SET @Start = CHARINDEX('font-size:',@HTMLText, @End+2)
    SET @End = CHARINDEX(';',@HTMLText,CHARINDEX('font-size:',@HTMLText, @End+2))
    SET @Length = (@End - @Start) + 1
    END
    RETURN LTRIM(RTRIM(@HTMLText))
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Overview: I have an array of 20 byte strings that needs to be stored
i have string stored in python variables, and i am outputting a html that
We have rtf text stored in our database that looks like the following: {\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0
I have Unicode strings stored in a database. Some of the character encodings are
I have stored values in my database that look like 5XXXXXX , where X
I have HTML code edited by FCKEditor stored in a database and would like
If I have strings/phrases like this stored in the database: What are Q-type Operations?
I have two strings, one is generated by PHP and stored in a database
I have values stored as strings in a DataTable where each value could really
If I have function names stored as strings in a Hashtable. Is there a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.