public class RegexTools extends Object
| Modifier and Type | Field and Description |
|---|---|
static Set<Character> |
CHARACTERS_TO_ESCAPE_ONLY_IN_CHAR_SELECTOR |
static Set<Character> |
CHARACTERS_TO_ESCAPE_OUTSIDE_CHAR_SELECTOR
Characters that need to be escaped in a regular expression.
|
| Modifier and Type | Method and Description |
|---|---|
static String |
characterSelector(char main,
char... alternatives)
Builds a regular expression that is a selector for a given character(s).
|
static String |
characterSelector(char mainCharacter,
Collection<Character> alternatives)
Builds a regular expression that is a selector for a given character(s).
|
static StringBuilder |
characterSelector(StringBuilder builder,
char mainCharacter,
Collection<Character> alternatives)
Appends to a given builder a regular expression that is a selector for a given character(s).
|
static String |
escaped(char character)
Escapes the character if it needs to in a regular expression that is part of a character selector.
|
static String |
escaped(char character,
boolean insideCharSelector)
Escapes the character if it needs to in a regular expression.
|
public static final Set<Character> CHARACTERS_TO_ESCAPE_OUTSIDE_CHAR_SELECTOR
public static String escaped(char character)
escaped(character, true).character - Character to escape.escaped(char, boolean)public static String escaped(char character, boolean insideCharSelector)
character - Character to escape.insideCharSelector - If true, CHARACTERS_TO_ESCAPE_ONLY_IN_CHAR_SELECTOR will be used to check if a character needs to be escaped; otherwise CHARACTERS_TO_ESCAPE_OUTSIDE_CHAR_SELECTOR will be used.public static StringBuilder characterSelector(StringBuilder builder, char mainCharacter, Collection<Character> alternatives)
builder - Builder to add the regular expression to.mainCharacter - The character to select.alternatives - Eventual alternatives.public static String characterSelector(char mainCharacter, Collection<Character> alternatives)
mainCharacter - The character to select.alternatives - Eventual alternatives.public static String characterSelector(char main, char... alternatives)
main - The character to select.alternatives - Eventual alternatives.Copyright © 2024 Miki. All rights reserved.