Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Javascript string bis zu einem bestimmten Zeichen abschneiden

NEWS

  • wichtiges UPDATE für controller 7.2.2 im stable
    HomoranH
    Homoran
    10
    1
    1.4k

  • Neues YouTube-Video: Visualisierung im Devices-Adapter
    BluefoxB
    Bluefox
    16
    1
    3.5k

  • Neuer ioBroker-Blog online: Monatsrückblick März/April 2026
    BluefoxB
    Bluefox
    8
    1
    3.3k

Javascript string bis zu einem bestimmten Zeichen abschneiden

Scheduled Pinned Locked Moved Skripten / Logik
5 Posts 2 Posters 8.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sveni_lee
    wrote on last edited by
    #1

    Ich habe einen String

    /Datengrab/Ordner/Ordner1/Ordner2
    

    nun möchte ich von diesem String "/Ordner2" abschneiden, dass nur noch "/Datengrab/Ordner/Ordner1" übrigbleibt.

    die bezeichnung der Ordner ändern sicht. Konstant bleibt nur "/" …

    Ich habe jetzt schon google gequält aber ich finde irgendwie nicht das pasende

    Gruß

    Sveni_Lee

    1 Reply Last reply
    0
    • paul53P Offline
      paul53P Offline
      paul53
      wrote on last edited by
      #2

      Vorschlag:

      var str = '/Datengrab/Ordner/Ordner1/Ordner2';
      str = str.split('/');
      str = str[0] + '/' + str[1] + '/' + str[2];
      
      

      Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
      Produktiv: Asus PN 42 / N100 / 8 GB / 500 GB

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sveni_lee
        wrote on last edited by
        #3

        okay danke und wie könnte mann nun jeweils den letzten entfernen?

        das können mal 3 oder 4 oder auch nur 2 Ordner sein…

        1 Reply Last reply
        0
        • paul53P Offline
          paul53P Offline
          paul53
          wrote on last edited by
          #4

          @sveni_lee:

          wie könnte mann nun jeweils den letzten entfernen? `

          var str = '/Datengrab/Ordner/Ordner1/Ordner2';
          var pos = str.lastIndexOf('/');
          str = str.substr(0, pos);
          
          

          Bitte verzichtet auf Chat-Nachrichten, denn die Handhabung ist grauenhaft !
          Produktiv: Asus PN 42 / N100 / 8 GB / 500 GB

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sveni_lee
            wrote on last edited by
            #5

            Danke, das klappt perfekt

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            Support us

            ioBroker
            Community Adapters
            Donate

            551

            Online

            33.0k

            Users

            83.3k

            Topics

            1.3m

            Posts
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
            ioBroker Community 2014-2026
            logo
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Home
            • Recent
            • Tags
            • Unread 0
            • Categories
            • Unreplied
            • Popular
            • GitHub
            • Docu
            • Hilfe