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 8479147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:56:37+00:00 2026-06-10T18:56:37+00:00

So I got this program that gives me a bunch of html-output with some

  • 0

So I got this program that gives me a bunch of html-output with some inline styling.

It typically looks like this:

<DIV style="position:absolute;top:126;left:324"><nobr><span class="ft010"><b>2011</b></span></nobr></DIV>
<DIV style="position:absolute;top:126;left:386"><nobr><span class="ft010"><b>2010</b></span></nobr></DIV>

Now I know this is a mess, but it’s what I get and changing it ain’t an option right now. What I however need to do is get a regexp to input px after the top and height attributes. So what I want looks like this:

<DIV style="position:absolute;top:126px;left:324px"><nobr><span class="ft010"><b>2011</b></span></nobr></DIV>
<DIV style="position:absolute;top:126px;left:386px"><nobr><span class="ft010"><b>2010</b></span></nobr></DIV>

The html is output as one long string so I need to find all occurences of top and left and add px after the numeric value. I’ve been trying lots of different solutions, but still can’t get it right. Would be greatful if someone could help me find the correct regexp for my issue. I’m horrible at that stuff.

  • 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-06-10T18:56:39+00:00Added an answer on June 10, 2026 at 6:56 pm
    $html = preg_replace('%(top|left|right|bottom)(:[0-9]{1,4})(;|")%', '$1$2px$3', $html);
    

    This should search for any of the CSS position keywords, followed by a colon, a number (1-4 digits long), and either a double quote (") or a semi-colon (;).

    It will then take all three of those parts (the parts within the parentheses) and stitch them back together with a px in the right place.

    http://codepad.viper-7.com/UjYCV3

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got this program that starts doing some tasks after I press the button,
I'm a newbie and I know that this C program which I got somewhere
I got a C# program which opens a EventWaitHandle like this to get triggered
I was just doing some stuff and wrote this program. I got the following
I've got a little objective-c utility program that renders a convex hull. (This is
I got this error Unhandled exception at 0x0049b946 in Program.exe: 0xC0000005: Access violation reading
While compiling a program in Java I got this big WARNING warning: [unchecked] unchecked
I'm new to C programming and I just came across this program and got
I have a program that fundamentally requires a lot of memory. However, for some
I've got a Haskell program that needs to execute a separate (third party) binary;

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.