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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:04:01+00:00 2026-06-15T10:04:01+00:00

I was using the command ‘string trimright’ to trim my string but I found

  • 0

I was using the command ‘string trimright’ to trim my string but I found that this command trims more than required.

My expression is “dssss.dcsss” If I use string trim command to trim the last few characters “.dcsss”, it trims the entire string. How can I deal with this?

Command:

     set a [string trimright "dcssss.dcsss" ".dcsss"]
     puts $a

Intended output:

    dcsss

Actual output

    ""
  • 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-15T10:04:02+00:00Added an answer on June 15, 2026 at 10:04 am

    The string trimright command treats its (optional) last argument as a set of characters to remove (and so .dcsss is the same as sdc. to it), just like string trim and string trimleft do; indeed, string trim is just like using both string trimright and string trimleft in succession. This makes it unsuitable for what you are trying to do; to remove a suffix if it is present, you can use several techniques:

    # It looks like we're stripping a filename extension...
    puts [file rootname "dcssss.dcsss"]
    
    # Can use a regular expression if we're careful...
    puts [regsub {\.dcsss$} "dcssss.dcsss" {}]
    
    # Do everything by hand...
    set str "dcssss.dcsss"
    if {[string match "*.dcsss" $str]} {
        set str [string range $str 0 end-6]
    }
    puts $str
    

    If what you’re doing really is filename manipulation, like it looks like, do use the first of these options. The file command has some really useful commands for working with filenames in a cross-platform manner in it.

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

Sidebar

Related Questions

I tried to create jar file using command line that I inserted into java
I found this documentation http://docs.jboss.org/hibernate/core/4.0/manual/en-US/html/toolsetguide.html#toolsetguide-s1-3 saying that we can run SchemaExport using command line
i try to install glance using command (os)mirror0@lab:~/tmp/glance$ python setup.py install but failed, why?
I'm using command line param Fo, command line is like this: file1.c /ZI /nologo
Some time ago I installed my PFX key into Container using command like this:
I'm running a program using command line in c# this program produce some logs
i want to calling form2 from form1 using command new form2().show, this.setVisible(false). I want
I have read that using command pattern is one of the most popular ways
I've installed paramiko using command: sudo apt-get install python-paramiko That installed pyCrypto too. Currently,
I am making this little program using command line arguments, I have like 90%

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.