[Solved] Finding first five digits in a var with Regex [closed]


You would need to use something like \d{5} which will match 5 digits.

Depending on the language you are using you would then access whatever the group matched.

For instance, in Java:

        String str ="AF1400006";
        Pattern p = Pattern.compile("\\d{5}");
        Matcher m = p.matcher(str);
        if(m.find())
            System.out.println(m.group());

Which yields the number you are after.

An example of the expression is available here.

3

solved Finding first five digits in a var with Regex [closed]