Skip to content

Commit

Permalink
Fix Regex expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
tiuweehan committed Sep 30, 2019
1 parent e4594e9 commit b817593
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/main/java/seedu/algobase/model/problem/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ public class Name {
"Names should only contain alphanumeric characters and spaces, and it should not be blank";

/*
* The first character of the name must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
* A name is any combination of the following characters: A-Z, a-z, ', . or whitespace.
* A name must contain at least one non-whitespace character.
*/
public static final String VALIDATION_REGEX = "[\\p{Alnum}][\\p{Alnum} ]*";
public static final String VALIDATION_REGEX = "^([A-z\\'\\.-ᶜ]+(\\s)*)*$";

public final String fullName;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/algobase/model/problem/Remark.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public class Remark {
public static final Remark DEFAULT_REMARK = new Remark();

/*
* A remark is a combination of characters or whitespaces.
* The first character of the solution must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = "[^\\s].*";
public static final String VALIDATION_REGEX = "^\\S[\\s\\S]*$";

public final String value;

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/seedu/algobase/model/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
*/
public class Tag {

public static final String MESSAGE_CONSTRAINTS = "Tags names should be alphanumeric";
public static final String VALIDATION_REGEX = "\\p{Alnum}+";
public static final String MESSAGE_CONSTRAINTS =
"Tags names should contain only alphabets, numbers, hyphen or underscore";
public static final String VALIDATION_REGEX = "^[a-zA-Z0-9_-]*$";

public final String tagName;

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/seedu/algobase/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ public static Problem[] getSampleProblems() {
new WebLink("https://leetcode.com/problems/two-sum/"),
new Description("Given an array of integers, "
+ "return indices of the two numbers such that they add up to a specific target."),
getTagSet("array", "hash table", "algorithm"),
getTagSet("array", "hash-table", "algorithm"),
new Difficulty("1.0"),
new Remark("You may assume that each input would have exactly one solution, "
new Remark("You may assume that each input would have exactly one solution, \n"
+ "and you may not use the same element twice."),
new Source("LeetCode")),
new Problem(new Name("Second Highest Salary"), new Author("LeetCode"),
Expand All @@ -49,16 +49,16 @@ public static Problem[] getSampleProblems() {
new Problem(new Name("Sudoku Solver"), Author.DEFAULT_AUTHOR,
new WebLink("https://leetcode.com/problems/sudoku-solver/"),
Description.DEFAULT_DESCRIPTION,
getTagSet("hash table", "backtracking", "algorithm"),
getTagSet("hash-table", "backtracking", "algorithm"),
new Difficulty("5.0"),
new Remark("You may assume that the given Sudoku puzzle will have a single unique solution."),
new Source("LeetCode")),
new Problem(new Name("A. Dawid and Bags of Candies"), Author.DEFAULT_AUTHOR,
new Problem(new Name("A Dawid and Bags of Candies"), Author.DEFAULT_AUTHOR,
new WebLink("https://codeforces.com/problemset/problem/1230/A"),
Description.DEFAULT_DESCRIPTION,
getTagSet("brute force"),
getTagSet("brute-force"),
new Difficulty("4.0"),
new Remark("time limit per test1 second\n" + "memory limit per test256 megabytes"),
new Remark("time limit per test1 second" + "memory limit per test256 megabytes"),
new Source("CodeForce")),
new Problem(new Name("Factorial"), new Author("Wee Han"), WebLink.DEFAULT_WEBLINK,
new Description("define a function factorial that takes in a number n "
Expand Down

0 comments on commit b817593

Please sign in to comment.