Menu

Removing the last character of a string if the last character is a "/"

GnuCOBOL
Jason
2023-11-23
2023-11-23
  • Jason

    Jason - 2023-11-23

    Hi folks,

    I can't figure this one out.

    As the title suggests. I have a string, if the last character of the string is a "/" then I want to remove it.

    Can anyone suggest how I can do this?

    Many thanks for any help and advice.

     
  • Vincent (Bryan) Coen

    examine blogs replacing ALL "/" for space.

    OR

    move LENGTH-AM to fred (pic 999 or what ever the max size is)
    if bloggs (fred:1) = "/" move space to bloggs (fred:1).

    Using examine is a one liner.

     
  • Jason

    Jason - 2023-11-23

    Yeah, i'm OK with the space. Once I've removed the "/" I append some more text to the URL.

    In fact i'm running a Python script from COBOL, the script uses a URL as an input, then I redirect the output of the script to a file, that the COBOL program picks up and processes. So the final thing looks a little like:

    myPythonScript.py https://www.example.com/robots.txt >> temp.file

    I call that using SYSTEM.

    The URLs come from a supplied text file, sometimes they end in "/" and sometimes not. So I parse the URLs to remove the "/" if it exists.

    Thank you for your help!

     
    • Vincent (Bryan) Coen

      On 23/11/2023 16:38, Jason wrote:

      Yeah, i'm OK with the space. Once I've removed the "/" I append some
      more text to the URL.

      In fact i'm running a Python script from COBOL, the script uses a URL
      as an input, then I redirect the output of the script to a file, that
      the COBOL program picks up and processes. So the final thing looks a
      little like:

      myPythonScript.py https://www.example.com/robots.txt >> temp.file

      I call that using SYSTEM.

      The URLs come from a supplied text file, sometimes they end in "/" and
      sometimes not. So I parse the URLs to remove the "/" if it exists.

      Thank you for your help!

      You are very welcome.

       

Log in to post a comment.