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

  • Home
  • SEARCH
  • 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 8771605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:49:53+00:00 2026-06-13T17:49:53+00:00

i want to replace the . into tokens like [dot] from below input to

  • 0

i want to replace the “.” into tokens like [dot] from below input to below output

input

this is a test.for a question. at stackoverflow.com the best place to learn. programming. test http://www.wikipedia.com

output

this is a test.for a question. at stackoverflow[dot]com the best place to learn. programming. test www[dot]wikipedia[dot]com

problems

  1. there is a possibly test.for we cant use good regex like /[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}/gi i think its best for using something like below better
  2. maybe i found a solution;

found = string.match(/([a-zA-Z0-9]+\.(com|co\.cc)|more\.domains)/gi);

this work great, i have a problem to join/replace them to the original string. any workarounds like how can we filter elements in array with regex in array with javascript?

how would you tackle this problem? btw im using nodejs other language is acceptable.

thanks

  • 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-13T17:49:55+00:00Added an answer on June 13, 2026 at 5:49 pm

    This handles www.example.com correctly:

    tld = ["com", "org", "edu", "net"] // feel free to add more
    
    var input = "this is a test.for a question. at www.stackoverflow.com " 
        + "the best place to learn. "
        + "programming.test wikipedia.com and windows.microsoft.edu";
    
    
    re = new RegExp('\\S+\\.(' + tld.join('|') + ')\\b', 'g')
    
    var dotted = input.replace(re, function($0) {
        return $0.replace(/\./g, "[dot]");
    });
    
    // this is a test.for a question. at www[dot]stackoverflow[dot]com the best place to learn. 
    // programming.test wikipedia[dot]com and windows[dot]microsoft[dot]edu
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like do something like this in one only query. REPLACE INTO table
i want to replace ALL comma , into ,<space> in all address table in
I want to replace an element into a specific position of a vector, can
I am trying to run a replace into DB call, but I only want
I want to replace all & characters into \& with String.gsub (or a other
Dear stackoverflow members, I have a small problem, I want to replace some characters
I want (need) to write an input filter, which replaces tokens with the values
my $c= 'ODD_`!£$%^&*(){}][@@;:/?.>,<|\' I want to replace all of them into as special character
I want to load a CSV file that looks like this: Acct. No.,1-15 Days,16-30
I want to replace all space characters into _ in names of all subfolders

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.