/* * [TestRegexFragments.java] * * Summary: Demonstrate techique of coding Regex patterns with fragments. * * Copyright: (c) 2009-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2009-04-28 */ package com.mindprod.example; import java.util.regex.Pattern; import static java.lang.System.*; /** * Demonstrate techique of coding Regex patterns with fragments. *

* Show some regexes coded with named fragments and alse the traditional way spelled out longhand. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2009-04-28 * @since 2009-04-28 */ @SuppressWarnings( { "UnusedAssignment" } ) public class TestRegexFragments { /* * Regex fragmant to find YYYY-MM-DD */ private static final String A_DASH = "[/\\-]"; /* * Regex fragmant to find YYYY-MM-DD */ private static final String A_DD = "[0-3]\\d"; /** * Regex to look for Windows EOL sequence */ private static final String A_EOL = "\\r\\n"; /** * regex fragment to match a = */ private static final String A_EQUAL = "="; /* * Regex fragmant to find YYYY-MM-DD */ private static final String A_MM = "\\d{2}"; /** * regex to find a number eg. 10 */ private static final String A_NUMBER = "\\d++"; /** * regex fragment to match a " */ private static final String A_QUOTE = "\""; /** * regex fragment to look for some spaces */ private static final String A_SPACES = "\\s++"; /** * regex fragment to look for