-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from 1c-syntax/feture/pattern
CIPattern
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
src/main/java/com/github/_1c_syntax/utils/CaseInsensitivePattern.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* This file is a part of 1c-syntax utils. | ||
* | ||
* Copyright © 2018-2020 | ||
* Alexey Sosnoviy <[email protected]>, Nikita Gryzlov <[email protected]> and contributors | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
* | ||
* 1c-syntax utils is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3.0 of the License, or (at your option) any later version. | ||
* | ||
* 1c-syntax utils is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with 1c-syntax utils. | ||
*/ | ||
package com.github._1c_syntax.utils; | ||
|
||
|
||
import lombok.experimental.UtilityClass; | ||
|
||
import java.util.regex.Pattern; | ||
import java.util.regex.PatternSyntaxException; | ||
|
||
/** | ||
* Pattern helper | ||
*/ | ||
@UtilityClass | ||
public class CaseInsensitivePattern { | ||
|
||
/** | ||
* Compiles the given regular expression into a pattern with CASE_INSENSITIVE and UNICODE_CASE | ||
* flags. | ||
* | ||
* @param regex | ||
* The expression to be compiled | ||
* | ||
* | ||
* @return the given regular expression compiled into a pattern with the given flags | ||
* @throws IllegalArgumentException | ||
* If bit values other than those corresponding to the defined | ||
* match flags are set in {@code flags} | ||
* | ||
* @throws PatternSyntaxException | ||
* If the expression's syntax is invalid | ||
*/ | ||
public static Pattern compile(String regex) { | ||
return Pattern.compile(regex, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE); | ||
} | ||
|
||
} |