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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:29:22+00:00 2026-05-27T08:29:22+00:00

I haven’t found any solution to a specific problem I’m having. I’m doing some

  • 0

I haven’t found any solution to a specific problem I’m having. I’m doing some XML parsing in which I would like to manipulate words within a string.

Given I have a case of: 'word, word word word' – words can be any string, as I have no knowledge what they would be in advance.

I’d like to be able to manipulate the string to obtain the following outcome: 'word., word word. word' – So, the first word and the third word I would like to append a '.' to the end of them.

What would be a suitable approach for this? Would regex be the best way?

  • 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-27T08:29:23+00:00Added an answer on May 27, 2026 at 8:29 am

    Assuming that words will be separated using the same character(s), I think that the simplest way would be to use indexOf(" ") and then use substring methods to add a dot before the returned index. Remember that you could also use lastIndexOf(" ") for appending the dot to the third word, or you could even specify the starting position of indexOf i.e

    String words = "word, word word word";
    String newWords
    
    int space1 = words.indexOf(" ");
    
    newWords = words.substring(0, space1) & "." & words.substring(space1 + 1);
    
    int lastSpace = newWords.lastIndexOf(" ");
    
    newWords = newWords.subString(0, lastSpace) & "." & newWords.subString(lastSpace + 1);
    

    (I think something along those lines would work, but I haven’t tested and I wrote it without an IDE)

    Of course, I’m not very familiar with regex and you haven’t really given that much information, so regex could potentially be an option, but I think that would require you to know the length(s) of the word(s), at the least.

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

Sidebar

Related Questions

I haven't found any information on MSDN regarding this problem. If we create an
Haven't done ASP.NET development since VS 2003, so I'd like to save some time
I haven't found any documentation on this or seen this done before, but is
haven't done much jquery and ran into a problem. I'd like to bind hover
I haven't made any thorough analysis of which implementation of PHP is the best
Haven't found in docs. Does java ResultSet supports query arguments,like jdbcTemplate? For example, something
Haven't fired up reflector to look at the difference but would one expect to
I haven't seen any questions relating to GNU autoconf/automake builds, but I'm hoping at
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Haven't found what i'm looking for so far. I want to redirect all my

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.