See if string is an ordinal Roman numeral using looser definition. - Java java.lang

Java examples for java.lang:Number

Description

See if string is an ordinal Roman numeral using looser definition.

Demo Code

/*   Please see the license information at the end of this file. */
//package com.java2s;

public class Main {
    /**   Ordinal Roman numeral pattern. */

    public static String looseOrdinalRomanNumeralPattern = "^\\.{0,1}M{0,3}(C[MD]|D?C{0,3})(X[CL]|L?X{0,3})"
            + "(I[XVU]|[UV]?I{0,4}|[UV]?I{0,3}J)"
            + "(th|TH|st|ST|nd|ND|rd|RD)\\.{0,1}$";

    /**   See if string is an ordinal Roman numeral using looser definition.
     */* w  w  w  . j  ava2  s  .  c om*/
     *   @param   s   The string.
     *
     *   @return      true if string is a valid Roman ordinal numeral
     *               using looser (older) definition.
     */

    public static boolean isLooseOrdinalRomanNumeral(String s) {
        return s.toUpperCase().matches(looseOrdinalRomanNumeralPattern);
    }
}

Related Tutorials