-
-
Save oleander/1988846 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.util.regex.Pattern; | |
public class Siffra { | |
public static void main(String[] args) { | |
Scanner myScanner = new Scanner(System.in); | |
String string0; | |
System.out.print("Skriv in en sträng: "); | |
string0 = myScanner.next(); | |
Pattern pattern = Pattern.compile("^\\d+"); | |
if(pattern.matcher(string0).find()) { | |
System.out.println("Strängen börjar med en siffra."); | |
} else { | |
System.out.println("Strängen börjar inte med en siffra."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment