Forum: PC-Programmierung How to test a string if it has the right format?


von Java checker (Gast)


Lesenswert?

Hello,
I have a string which a user should input into my program. And I wanna 
check if the string always has the correct format. What is the best way 
to check this Format in java ?

[One digit 0-9];[Hex code like 0x21DE40AF];[Digit 0-99];[One Digit 0-9]

Thanks

von gdfgdfgdg (Gast)


Lesenswert?

standard Clib

regexec
regcomp

von gdfgdfgdg (Gast)


Lesenswert?

sorry ^^ don't see "java" ...

but search for "regex" - regular expression

von quotendepp (Gast)


Lesenswert?

if i'm not completely wrong there's something like String.match(pattern) 
which uses regex. and regex absolutely suitable for this task

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.