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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:05:47+00:00 2026-05-16T15:05:47+00:00

$string = ‘http://site.com/category/1/news/2134/’; // ‘1’ is dynamic How can I change 1 to any

  • 0
$string = 'http://site.com/category/1/news/2134/'; // '1' is dynamic

How can I change 1 to any number I want?

Can’t call parts of the string, its just a text-like variable.

It can be done with some true regex.

  • 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-16T15:05:48+00:00Added an answer on May 16, 2026 at 3:05 pm
    $string = preg_replace('~(?<=category/)[0-9]+(?=/news)~', '56', $string);
    

    This replaces the number by 56.

    This approach uses a regex with assertions.

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

Sidebar

Related Questions

String s=asd http://www.blabla.com/bla/foo wert fgh; I want a string: asd <a href='http://www.blabla.com/bla/foo'>http://www.blabla.com/bla/foo</a> wert fgh
String to pull from : http:\/\/c.ypcdn.com\/2\/c\/rtd?vrid=357c99c36bd7ed631eda2e43fc9e30f8&rid=283d465f-f63b-4b0d-90b0-be6c12ed7617&ptid=943aw4l8qj&ypid=11720135&lid=194823099&tl=6&lsrc=SP&dest=http%3A%2F%2FCleanation.com RegEx I have used before: www\..*?\.\w{2,5} However the
string url = http://google.com/index.html; WebClient client = new WebClient(); Stopwatch sw = new Stopwatch();
String#to_i returns 0 when the string does not match any number characters, and I
String str = abcde123_92qwq_1a_02x_1e; I want to replace the first string part between the
string one = find; combobox1.text = one; I want to use one i.e string
string s = <script type=text/javascript src=/stepcarousel.js></script> How can I get the data inside the
String pattern = @^(\d{11})$; String input = You number is:11126564312 and 12234322121 \n\n23211212345; Match
String a=aaa; String b=bbb; String c=ccc; String d=ddd; String p,q,r,s; How can I assign
String data=this we want append in that file; byte[] getbyte = data.getBytes(); outputstream.write(getbyte); outputstream.flush();

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.