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.

String auf Sonderzeichen prüfen

Empfohlene Antworten

Veröffentlicht

Hi,

ich möchte einen gegebenen String auf bestimmte ungültige Zeichen prüfen. Dazu habe ich bisher die folgende Möglichkeit gefunden:


//Pattern mit den erlaubten Zeichen

String pattern =  "[\\u0020-\\u007e\\u00a2-\\u00a7\\u00c0-\\u00ff]*";

String testStr = "Hallo³";


//Verwendung von java.util.regex.Matcher und java.util.regex.Pattern;

Pattern p = Pattern.compile(pattern);

Matcher m = p.matcher(test);

boolean b = m.matches();

Der Teil läuft auch soweit. Nun würde ich gern wissen, ob ich eine Möglichkeit habe, herauszufinden, an welcher Stelle das fehlerhafte Zeichen steht.

Grüße

Dejay82

indexOf ?

indexOf(String str)

Returns the index within this string of the first occurrence of the specified substring.

Bringt relativ wenig mit einem Pattern. Du suchst wohl eher das aus der Klasse Matcher:

int start() 

          Returns the start index of the previous match.

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.