Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

java script - right(string, 3)

Empfohlene Antworten

Hi zusammen,

ich brauche eine Funktion unter Java Script die mir aus einem String alle Zeichen nach einem Punkt zurück gibt. Ziel ist es eine Dateiendung zu überprüfen.

Bsp. bei "test.txt" brauche ich die Endung "txt"

bei "blah.ef" brauche ich "ef" als Rückgabe

bei "blah2" entsprechend ""

Hat jemand eine Idee???

Original geschrieben von Naberius

ich brauche eine Funktion unter Java Script die mir aus einem String alle Zeichen nach einem Punkt zurück gibt. Ziel ist es eine Dateiendung zu überprüfen.

Bsp. bei "test.txt" brauche ich die Endung "txt"

bei "blah.ef" brauche ich "ef" als Rückgabe

bei "blah2" entsprechend ""

--- Variante 1, nicht so sicher:

function getEndung( str ) {

var b = str.split(".")

if ( b.length == 1 ) {

return "";

} else {

return b[1] ;

}

}

alert( getEndung( "blabla.txt" ) );

---Variante 2, sicherer:

function getEndung( str ) {

var pos = str.lastIndexOf( "." );

return str.substr( pos+1, str.length-pos );

}

alert( getEndung( "bla.txt" ) );

(edit) ach, depp ich:

function getEndung( str ) {

var pos = str.lastIndexOf( "." );

return str.substring( pos+1, str.length );

}

alert( getEndung( "bla.txt" ) );

SUPER!!!

Danke für die schnelle Antwort!!!:OD :OD :OD

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.