Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Visualisierung
    4. [gelöst] Wort in Text markieren

    NEWS

    • Neues Video "KI im Smart Home" - ioBroker plus n8n

    • Neues Video über Aliase, virtuelle Geräte und Kategorien

    • Wir empfehlen: Node.js 22.x

    [gelöst] Wort in Text markieren

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mikiline last edited by

      Hi zusammen,

      hat mir jemand bitte ein Beispiel wie ich ein bestimmtes Wort in bzw. aus einem HTML Text farblich ändern kann?

      Ich möchte ein bestimmtes Wort aus dem ical rot darstellen.

      Darstellung des ical erfolgt im Widget Basic-String (unescaped)

      Danke für die Hilfe

      1 Reply Last reply Reply Quote 0
      • Bluefox
        Bluefox last edited by

        Du erzeigst neue Variable und dann:

        const icalOtherID = 'myiCal';
        const icalNormalID = 'ical.deine.echte.ID';
        function colorize(html) {
        	if (!html) return;
        	html = html.replace(/bestimmtes Wort/g, 'bestimmtes Wort');
        	setState(icalOtherID, html);
        }
        
        createState(icalOtherID, () => {
        	on(icalNormalID, obj => colorize(obj.state.val));
        	getState(icalNormalID, (err, state) => state && colorize(state.val));
        });
        
        
        1 Reply Last reply Reply Quote 0
        • M
          mikiline last edited by

          Vielen Dank! Funktioniert 🙂

          1 Reply Last reply Reply Quote 0
          • P
            pix last edited by

            Hallo,

            hab das mal so gelöst:

            Suche searchStringPattern in beschreibung oder in titel

            let searchStringPatter = /TESTTEXT/gi;
            // Position des Suchworts im Text markieren
            if (searchStringPattern.test(titel) === true) titel = titel.replace(searchStringPattern,"<mark>><</mark>");
            if (searchStringPattern.test(beschreibung) === true) beschreibung = beschreibung.replace(searchStringPattern,"<mark>><</mark>");                            
            
            

            261_bildschirmfoto_2018-07-15_um_20.15.03.jpg

            Gruß

            Pix

            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            Support us

            ioBroker
            Community Adapters
            Donate

            593
            Online

            32.1k
            Users

            80.7k
            Topics

            1.3m
            Posts

            3
            4
            405
            Loading More Posts
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes
            Reply
            • Reply as topic
            Log in to reply
            Community
            Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
            The ioBroker Community 2014-2023
            logo