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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:22:54+00:00 2026-05-22T19:22:54+00:00

Need help with regex javascript , i tried few but didn’t work i want

  • 0

Need help with regex javascript , i tried few but didn’t work

i want to replace the the following string which is a url. The values 200, 400 are dynamic in the below string

url=http://www.test.com?debug=true&MAXWIDTH:200+MAXHEIGHT:400

with ,900 , 900 always and the result should be

after regex i want the url string contains the below value

url=http://www.test.com/?debug=true&MAXWIDTH:900+MAXHEIGHT:900
  • 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-22T19:22:56+00:00Added an answer on May 22, 2026 at 7:22 pm
    var replaceMaxWidthAndHeight = function(str, newWidthAndHeight) {
      var i=0;
      return str.replace(/\s*(MAXWIDTH|MAXHEIGHT)\s*:\s*(\d+)\s*/g, function(s, m1) {
        return m1 + ':' + newWidthAndHeight[i++];
      });
    };
    
    var s1 = "url=http://www.test.com/?debug=true&MAXWIDTH:200+MAXHEIGHT: 400";
    var s2 = replaceMaxWidthAndHeight(s1, [900, 900]);
    s2; // => "url=http://www.test.com/?debug=true&MAXWIDTH:900+MAXHEIGHT:900"
    s2 = replaceMaxWidthAndHeight(s1, [10, 20]);
    s2; // => "url=http://www.test.com/?debug=true&MAXWIDTH:10+MAXHEIGHT:20"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help with javascript and regex.I want to remove some text in
Need Some Help With Regex: I want to replace [url=http://youtube.com]YouTube.com[/url] with <a href=http://youtube.com>YouTube.com</a> the
I need help to create a regex (for JavaScript .match and PHP preg_match) that
I'm using plain vanilla JavaScript and need some help with my regex. Money in
i need your help with a regex in javascript. I've got an a-tag with
I need help with a Regex expression to valid an ID pattern which is
Need help using regex and powershell to accomplish the following. I have the following
i need your help with an regex in Javascript, again. Sometimes i have empty
I need to replace a button using a Regex in JavaScript and was wondering
I am trying to validate a password string with javascript and need some help

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.