openlang

Extracting one section of a tcl string

With tcl I'm attempting to break apart Reports/Report#2.rpt and keep just Report#2.rpt ; I tried this approach, but it produced no output at all when I ran it :

set reportPath "Reports/Report#2.rpt"
set reportName [echo $reportPath |cut -d "/" -f 2]

The conversation continues 2

Follow the reasoning
  1. Permalink

    crochet's suggestion of file tail fits perfectly when stripping the directory portion off a pathname.

    For a "CSV" string whose separator is a slash, combine split with lindex instead

    set reportName [lindex [split $reportPath /] end]

Other sides of the same question

  1. Escaping percent characters when calling String.Format?

    My strings.xml file holds a SQL query, and I'm trying to construct the finished string in code with String.Format. The SELECT…

    Replies 3Latest activity java
  2. Formatting strings with F#

    I'm building an F# library for the first time Using string.Format gives me a complaint saying that the function doesn't exist…

    Replies 2Latest activity fsharp
  3. Ruby regex fails when constructed from a stored string

    I am keeping a regular expression in the following variable - pattern_text = "/\A([^@\s]+)@((?:c-d+\.)+(in|com))\z/". Saving…

    Replies 2Latest activity ruby