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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:16:03+00:00 2026-06-13T13:16:03+00:00

hello im doing something like how to replace dots inside quote in sentence with

  • 0

hello im doing something like how to replace dots inside quote in sentence with regex

var string = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. "Vestibulum interdum dolor nec sapien blandit a suscipit arcu fermentum. Nullam lacinia ipsum vitae enim consequat iaculis quis in augue. Phasellus fermentum congue blandit. Donec laoreet, ipsum et vestibulum vulputate, risus augue commodo nisi, vel hendrerit sem justo sed mauris." Phasellus ut nunc neque, id varius nunc. In enim lectus, blandit et dictum at, molestie in nunc. Vivamus eu ligula sed augue pretium tincidunt sit amet ac nisl. "Morbi eu elit diam, sed tristique nunc."';

// seperate the quotes
var quotes = string.match(/"(.)+?"/g);
var test = [];

// for each quotes
for (var i = quotes.length - 1; i >= 0; i--) {

    // replace all the dot inside the quote
    test[i] = quotes[i].replace(/\./g, '[dot]');
};

console.log(test);

lets say we already make the change with the regex, but im stuck at how can we join it back to the existing var string as my result is seperated in var test ? or theres a better way?

the output should be something like

Lorem ipsum dolor sit amet, consectetur adipiscing elit. “Vestibulum interdum dolor nec sapien blandit a suscipit arcu fermentum[dot]Nullam lacinia ipsum vitae enim consequat iaculis quis in augue[dot] Phasellus fermentum congue blandit[dot] Donec laoreet, ipsum et vestibulum vulputate, risus augue commodo nisi, vel hendrerit sem justo sed mauris[dot]” Phasellus ut nunc neque, id varius nunc. In enim lectus, blandit et dictum at, molestie in nunc. Vivamus eu ligula sed augue pretium tincidunt sit amet ac nisl. “Morbi eu elit diam, sed tristique nunc[dot]”

*ps im not sure the title is corrent

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-13T13:16:04+00:00Added an answer on June 13, 2026 at 1:16 pm

    You could instead just split at ", do the replacement in every second array element, then join again:

    var parts = string.split('"');
    for (var i = 1; i < parts.length; i += 2) {
        parts[i] = parts [i].replace(/\./g, '[dot]');
    };
    string = parts.join('"');
    

    Since split will create an empty string at index 0 if the string starts with " this should work in all cases.

    Note that the edge case of a trailing unmatched " will lead to every dot after that " to be replaced as well. If you do not want this, simply change the for condition to i < parts.length - 1.

    JSFiddle Demo

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

Sidebar

Related Questions

EDIT: I would like to avoid doing something like this: var str = 'Hello';
I'm trying to replace something like: $text = Hello <--name--> !!; echo str_replace(--,?,$text); Expected:
I have a python module_A which is doing something like this: myvar = Hello
Hi I trying do something like that: I've got some string - 'Hello World!'
Is it possible to do something like: string word = Hello; word[3] = null;
I am using System.Windows.Forms.RichTextBox and doing something like RichTextBox1.Text = Hello World; But after
Currently I am doing this: I have text that looks like: Hello ${user.name}, this
I'm trying something like this Output.py print Hello Input.py greeting = raw_input(Give me the
I have an array that looks something like this array(7) { [0]=> hello,pat1 [1]=>
I'm doing a non-greedy match like this '(?<C2>.+?)' to find a group inside 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.