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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:14:14+00:00 2026-05-31T15:14:14+00:00

The title might be confusing. Just say I have a newspaper article. I want

  • 0

The title might be confusing. Just say I have a newspaper article. I want to cut it off around a certain point, say 4096 characters, but not in the middle of a word, rather before the last word that takes the length over 4096. Here is a short example:

"This is the entire article."

If I want to cut it off before a word that takes the total length over 16 characters, here is the result I would want:

"This is the entire article.".function
=> "This is the"

The word “entire” takes the total length over 16, so it must be removed, along with all characters after it, and the space before it.

Here is what I don’t want:

"This is the entire article."[0,15]
=> "This is the ent"

It looks easy in writing, but I don’t know how to put it into programming.

  • 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-31T15:14:15+00:00Added an answer on May 31, 2026 at 3:14 pm

    How about something like this for your example:

    sentence = "This is the entire article."
    length_limit = 16
    last_space = sentence.rindex(' ', length_limit) # => 11
    shortened_sentence = sentence[0...last_space]   # => "This is the"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

title might be confusing, but lets say I have a template: template <typename T,
the title might be a little bit confusing, let me explain, ;) I have
Title might be a bit confusing, so let me explain. I have a website
Okay, the post title might be a little confusing. I have this code: class
Okay so the title might sound a bit confusing, but here's what I want
The title might have been a bit confusing but I can clarify here. I'm
I might have written a pretty confusing title but my question is rather simple.
Does that title sound confusing? I thought it might well anyways. When I person
I asked a question , title of which might have been misleading so I'm
the title might be too generic, but I have a very specific question about

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.