Schedule-Creator

Java GUI to create schedules for UNCG students
git clone git://git.wrycode.com/wrycode/archive/Schedule-Creator.git
Log | Files | Refs | README

commit 6ed46827b407dd2225581d9bcdf40e756f481be7
parent e43b2b2d6df1ea39077d4317e436e79a56864a64
Author: Nick Econopouly <wry@mm.st>
Date:   Tue, 18 Feb 2020 16:46:05 -0500

Merge pull request #6 from cloud0x9/sfar

Add comments and style guide to the ParseData class
Diffstat:
Msrc/ScheduleCreator/ParseData.java | 37+++++++++++++++++++++++++------------
1 file changed, 25 insertions(+), 12 deletions(-)

diff --git a/src/ScheduleCreator/ParseData.java b/src/ScheduleCreator/ParseData.java @@ -1,32 +1,46 @@ package ScheduleCreator; + +/** + * This class parses through text file's using regex and outputs the results. + * Last updated: February 18, 2020 + * + * @author Sfar + */ import java.io.*; import java.util.regex.*; -public class ParseData { - - static void parse() throws IOException { - +public class ParseData { + + protected static void parse() throws IOException { + + //Temporary string needed to parse text file, will be removed later. + String line; + //this is the regex expression that grabs abbreviated class name with section, time, and day of the class // ex. CSC 340-01, 5:30-6:45, T H (days) Pattern regex = Pattern.compile("\\b[A-Z]{3}\\b.\\b[0-9]{3}\\b.* [0-9]{2}\\b|([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]|([AaPp][Mm])\\b|TR\\b|MW\\b|MWF\\b|M\\b|T\\b|W\\b|R\\b|F\\b/g"); + //alternative regex for above, this one includes CRN codes. //("[0-9]{5}|\b[A-Z]{3}\b.\b[0-9]{3}\b.* [0-9]{2}\b|([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]|([AaPp][Mm])\b|TR\b|MW\b|MWF\b|M\b|T\b|W\b|R\b|F\b"); - // A FileReader, this will be changed later + + // A FileReader, this is a hardcoded example, and should be changed later. BufferedReader r = new BufferedReader(new FileReader("TestFile.txt")); + Pattern regexx = Pattern.compile("\\b[A-Z]{3}\\b.\\b[0-9]{3}\\b.* [0-9]{2}\\b|([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]|([AaPp][Mm])\\b|TR\\b|MW\\b|MWF\\b|M\\b|T\\b|W\\b|R\\b|F\\b/g"); + // matching lines with regex expression - String line; while ((line = r.readLine()) != null) { - // find lines that match + // find lines that match Matcher regexMatcher = regex.matcher(line); + //loop through line by line to find matches, will be changed later. while (regexMatcher.find()) { // Get the starting position of the text int start = regexMatcher.start(0); // Get ending position int end = regexMatcher.end(0); - // Print whatever matched. + // Print whatever matched. System.out.println(line.substring(start, end)); - } + } + } } - } -}- \ No newline at end of file +}