thomas1972
Goto Top

Prüfen ob im String Sonderzeichen enthalten sind (es dürfen nur Zahlen und Buchstaben (Groß und Kleinschreibung) sein

Hallo Zusammen,

bin auf der Suche nach Prüfung einer Variable auf Sonderzeichen.
D.h es sind nur Zahlen und Buchstaben (Groß und Kleinschreibung) erlaubt (auch in Kombination),
sobald er irgend ein Sonderzeichen im String findet, soll er einen Hinweis ausgeben.

Für euch sicherlich ein klacks..


Grüße aus München.

Content-Key: 634070

Url: https://administrator.de/contentid/634070

Printed on: April 24, 2024 at 19:04 o'clock

Member: Xerebus
Xerebus Dec 20, 2020 at 15:37:58 (UTC)
Goto Top
Hallo

echt jetzt?
wo ist sie denn, die Variable?

Was hast du denn schon versucht?
Mitglied: 146707
146707 Dec 20, 2020 updated at 15:53:53 (UTC)
Goto Top
str = "Hallo-Test"  
With CreateObject("vbscript.regexp")  
    .IgnoreCase = True
    .Pattern = "[^a-z\d]"  
    if .Test(str) then
        MsgBox "Text enthält ungültige Zeichen.",vbExclamation  
    end if
End with

https://www.vba-tutorial.de/applikation/regexp.htm
Member: mayho33
mayho33 Dec 20, 2020 updated at 21:20:03 (UTC)
Goto Top
Zitat von @thomas1972:

Für euch sicherlich ein klacks..


Und welche Script / Programmiersprache nochmal?

In C# etwa so:

RegEx.Match("De1NeM&m4", @"(\w\d)" RegexOption.IgnoreCase).Success  
Mitglied: 146707
146707 Dec 20, 2020 at 22:10:21 (UTC)
Goto Top
Zitat von @mayho33:
Und welche Script / Programmiersprache nochmal?
Ein Blick auf die Kategorie lohnt sich ...
Member: mayho33
mayho33 Dec 21, 2020 at 01:16:40 (UTC)
Goto Top
Zitat von @146707:

Zitat von @mayho33:
Und welche Script / Programmiersprache nochmal?
Ein Blick auf die Kategorie lohnt sich ...

Tatsache! Die ist mir echt noch nie aufgefallen :O