Class PatternConsts

java.lang.Object
org.omegat.util.PatternConsts

public final class PatternConsts extends Object
Constant patterns, used in different other classes.
  • Field Details

    • CHECK_CUSTOM_PATTERN_DEFAULT

      public static final String CHECK_CUSTOM_PATTERN_DEFAULT
      Tag Validation Option: check user defined tags according to regexp.
      See Also:
    • XML_ENCODING

      public static final Pattern XML_ENCODING
      Compiled pattern to extract the encoding from XML file, if any. Found encoding is stored in group #1.
    • XML_HEADER

      public static final Pattern XML_HEADER
      compiled pattern to match XML header
    • XML_DOCTYPE

      public static final Pattern XML_DOCTYPE
      Compiled pattern to extract the DOCTYPE declaration from XML file, if any. Groups:
      #1 - DOCTYPE name
      #3 - PUBLIC DOCTYPE URL
      #5 - SYSTEM DOCTYPE URL
    • XML_ROOTTAG

      public static final Pattern XML_ROOTTAG
      Compiled pattern to extract the root tag from XML file, if any. Group #1 should contain the root tag.
    • XML_XMLNS

      public static final Pattern XML_XMLNS
      Compiled pattern to extract the xlmns declaration from an XML file, if any. Group #2 should contain the xmlns declaration. E.g., http://www.w3.org/2001/XMLSchema-instance
    • HTML_ENCODING

      public static final Pattern HTML_ENCODING
      compiled pattern to extract the encoding from HTML file, if any
    • HTML5_ENCODING

      public static final Pattern HTML5_ENCODING
      compiled pattern to extract the encoding from HTML5 file, if any
    • HTML_HEAD

      public static final Pattern HTML_HEAD
      Compiled pattern to look for HTML file HEAD declaration. Using [^e] instead of . prevents confusing <head> with <header> from HTML 5
    • HTML_HTML

      public static final Pattern HTML_HTML
      compiled pattern to look for HTML file HTML declaration
    • HTML_BR

      public static final Pattern HTML_BR
      Pattern for detecting html <BR> tags
    • OMEGAT_TAG_ONLY

      public static final Pattern OMEGAT_TAG_ONLY
      Pattern that matches full string containing in full and only omegat-specific tag (without leading < and trailing >).
    • OMEGAT_TAG

      public static final Pattern OMEGAT_TAG
      Pattern that matches omegat-specific tags (with leading < and trailing > in any place of a string).
    • OMEGAT_TAG_SPACE

      public static final Pattern OMEGAT_TAG_SPACE
      Pattern that matches omegat-specific tags (with leading < and trailing > in any place of a string) plus a space after it.
    • SPACE_OMEGAT_TAG

      public static final Pattern SPACE_OMEGAT_TAG
      Pattern that matches omegat-specific tags (with leading < and trailing > in any place of a string) with a space before it.
    • OMEGAT_TAG_DECOMPILE

      public static final Pattern OMEGAT_TAG_DECOMPILE
      Pattern that matches omegat-specific tags (with leading < and trailing > in any place of a string) and decompiles them into pieces:
      1. leading /, if any
      2. tag shortcut
      3. tag number
      4. trailing /, if any
      Call matcher.group(n) to get each piece.
    • PROTECTED_PARTS_PAIRED_TAG_DECOMPILE

      public static final Pattern PROTECTED_PARTS_PAIRED_TAG_DECOMPILE
      Pattern that matches paired tag in protected parts
      1. opening tag
      2. text between tags
      3. closing tag
      Call matcher.group(n) to get each piece.
    • EQUIV_TEXT_ATTRIBUTE_DECOMPILE

      public static final Pattern EQUIV_TEXT_ATTRIBUTE_DECOMPILE
      Pattern that matches an equiv-text attribute as used in XLIFF inline codes.
    • SPACY_REGEX

      public static final Pattern SPACY_REGEX
      Pattern that detects space-only regular expressions.
    • LANG_AND_COUNTRY

      public static final Pattern LANG_AND_COUNTRY
      Pattern that detects language and country, with an optionnal script in the middle.
    • DICTIONARY_ZIP

      public static final Pattern DICTIONARY_ZIP
      Pattern for detecting remote dictionary file archives
    • SPACE_TAB

      public static final Pattern SPACE_TAB
    • REGEX_VARIABLE

      public static final Pattern REGEX_VARIABLE
      Pattern for regular expression variable : $n, where n is a number, but should not be preceded by backslash
    • LINE_ENDING

      public static final Pattern LINE_ENDING
      compiled pattern to match line ending win/mac/linux
    • PRINTF_VARS

      public static final Pattern PRINTF_VARS
      Pattern for detecting the placeholders in a printf-function string which can occur in languages like php, C and others. placeholder ::= "%" [ARGUMENTSWAPSPECIFIER] [SIGNSPECIFIER] [PADDINGSPECIFIER] [ALIGNMENTSPECIFIER] [WIDTHSPECIFIER] [PRECISIONSPECIFIER] TYPESPECIFIER NUMBER ::= { "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" } ARGUMENTSWAPSPECIFIER = NUMBER "$" SIGNSPECIFIER ::= "+" | "-" PADDINGSPECIFIER ::= " " | "0" | "'" CHARACTER ALIGNMENTSPECIFIER ::= "" | "-" WIDTHSPECIFIER ::= NUMBER PRECISIONSPECIFIER ::= "." NUMBER TYPESPECIFIER ::= "b" | "c" | "d" | "e" | "E" | "f" | "F" | "g" | "G" | "i" | "n" | "o" | "p" | "s" | "u" | "x" | "X" | "%" //c++: [cdieEfgGosuxXpn%] //php: [bcdeufFosxX%] NB: Because having space as paddingspecifier leads to many false matches in regular text, and space being the default padding specifier in php, and being able to have space or 0 as padding specifier by prefixing it with ', and having the padding specifier not being used frequently in most cases, the regular expression only corresponds with quote+paddingspecifier. NB2: The argument swap specifier gives explicit ordering of variables, without it, the ordering is implicit (first in sequence is first in order) Example in code: echo printf(gettext("%s is very %s"), "OmegaT", "great");
    • SIMPLE_PRINTF_VARS

      public static final Pattern SIMPLE_PRINTF_VARS
      Pattern for detecting the placeholders in a printf-function string. It detects only simple placeholders, without SIGN-, PADDING-, ALIGNMENT- and WIDTH specifier.
      See Also:
    • SIMPLE_JAVA_MESSAGEFORMAT_PATTERN_VARS

      public static final Pattern SIMPLE_JAVA_MESSAGEFORMAT_PATTERN_VARS
    • SIMPLE_PLACEHOLDERS

      public static final Pattern SIMPLE_PLACEHOLDERS
      Pattern for detecting OmegaT-tags and other placeholders (extended sprintf-variant) in texts
  • Method Details

    • getPlaceholderPattern

      public static Pattern getPlaceholderPattern()
      Returns the placeholder pattern (OmegaT tags, printf tags, java MessageFomat tags, custom tags, combined according to user configuration)
      Returns:
      the pattern
      See Also:
    • updatePlaceholderPattern

      public static void updatePlaceholderPattern()
      Resets the placeholder pattern. Use it when the user has changed tagvalidation configuration.
    • getRemovePattern

      public static Pattern getRemovePattern()
    • updateRemovePattern

      public static void updateRemovePattern()
      Resets the remove pattern. Use it when the user has changed tagvalidation configuration.
    • getCustomTagPattern

      public static Pattern getCustomTagPattern()
    • updateCustomTagPattern

      public static void updateCustomTagPattern()
      Resets the remove pattern. Use it when the user has changed tagvalidation configuration.