Class Regex

java.lang.Object
com.luchersol.core.util.Regex

public final class Regex extends Object
Utility class containing commonly used regular expression patterns.

This class provides reusable String constants representing validated regex patterns for typical validation scenarios such as numbers, identifiers, and network addresses.

All patterns are designed to be used with Pattern and Matcher.

  • Field Details

    • SPECIAL_CHARACTERS

      public static final String SPECIAL_CHARACTERS
      Matches strings containing at least one special character.

      Special characters included:

      ! @ # $ % ^ & * ( ) , . ? " : { } | < >

      Example matches:

      • hello!
      • pass@word
      See Also:
    • DIGIT

      public static final String DIGIT
      Matches one or more digits.

      Equivalent to:

      [0-9]+

      Example matches:

      • 123
      • 007
      See Also:
    • HEXADECIMAL

      public static final String HEXADECIMAL
      Matches hexadecimal numbers, optionally prefixed with 0x or 0X.

      Example matches:

      • FF
      • 0x1A3F
      See Also:
    • DNI

      public static final String DNI
      Matches a Spanish DNI (Documento Nacional de Identidad).

      Format:

      • 8 digits
      • 1 uppercase letter

      Example match:

      12345678Z

      Note: This pattern validates only the format, not the correctness of the control letter.

      See Also:
    • IPV4

      public static final String IPV4
      Matches a valid IPv4 address.

      Each octet must be between 0 and 255.

      Example matches:

      • 192.168.1.1
      • 8.8.8.8
      See Also:
    • IPV6

      public static final String IPV6
      Matches a valid IPv6 address (compressed and full forms).

      Supports:

      • Full notation
      • Compressed notation (::)

      Example matches:

      • 2001:0db8:85a3:0000:0000:8a2e:0370:7334
      • 2001:db8::1
      See Also: