-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into fileDescr
* upstream/master: Localization: French: Translation of a new string (#3212) Fix #2775: Hyphens in last names are properly parsed (#3209) Followup to Issue #3167 (#3202) Update mockito-core from 2.9.0 -> 2.10.0
- Loading branch information
Showing
25 changed files
with
756 additions
and
38 deletions.
There are no files selected for viewing
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
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
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
33 changes: 33 additions & 0 deletions
33
src/main/java/org/jabref/logic/integrity/BracesCorrector.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,33 @@ | ||
package org.jabref.logic.integrity; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class BracesCorrector { | ||
|
||
private static final Pattern PATTERN_ESCAPED_CURLY_BRACES = Pattern.compile("(\\\\\\{)|(\\\\\\})"); | ||
//private static final Pattern PATTERN_ESCAPED_CLOSING_CURLY_BRACE = Pattern.compile(""); | ||
|
||
public static String apply(String input) { | ||
if (input == null) { | ||
return null; | ||
} else { | ||
Matcher matcher = PATTERN_ESCAPED_CURLY_BRACES.matcher(input); | ||
String addedBraces = input; | ||
String c = matcher.replaceAll(""); | ||
|
||
long diff = c.chars().filter(ch -> ch == '{').count() - c.chars().filter(ch -> ch == '}').count(); | ||
while (diff != 0) { | ||
if (diff < 0) { | ||
addedBraces = "{" + addedBraces; | ||
diff++; | ||
} else { | ||
addedBraces = addedBraces + "}"; | ||
diff--; | ||
} | ||
} | ||
return addedBraces; | ||
} | ||
} | ||
|
||
} |
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
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
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
Oops, something went wrong.