Java simplifies search patterns

BIS
2 min readFeb 6, 2021

--

A most practical way of writing simple Java pattern recognition is using Java.

Pattern API has a simplified API that has been used for our Question Bank Database and Online Test Software. Please see java.util.regex.The pattern for full details. Here we will outline practical usages of it.

There are a number of factors to consider for Exam Software to see if repeats exist within description examination which is misleading while marking the papers electronically and gives false impressions for the character and word count. Examination Software has used Pattern.compile() method of the API to increase efficiency for the fast marking of descriptive answers. Our Question Bank Software has multiple ways of editing and marking questions and one of the techniques adopted is subjective marking with pattern recognition.

Below is the code used for marking Online Exam Software:

static void compileTest(final String patternMatch, final String text) {
Pattern pattern = Pattern.compile(patternMatch, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(text);
boolean matches = matcher.matches();
System.out.println("matches = " + matches);
}

Online Test System provides a better way for repeats, which means more than once compile function can be used.

matchesTest(".*ex.*", text);
matchesTest(".*Hemant.*", text);
matchesTest(".*hemant.*", text);

Online Examination Software also requires splitting descriptive tests into a number of words and then isolate for marking. Similarly for assessments as well.

Online Assessment System uses Pattern.split() to breaks answers and identifies whether a pattern exists or know.

static void splitTest(final String patternMatch, final String text) {
Pattern pattern = Pattern.compile(patternMatch);

String[] split = pattern.split(text);

System.out.printf("split.length = %d\n", split.length);

for (String element : split) {
System.out.printf("element = %s\n", element);
}
}

Here is an example used for Assessment Management Software:

text = "I want id to be split by the id and id only";
splitTest("id", text);

Examination Management Software

Exam Management Software

Finally and more importantly for standalone pattern matching, here is the code excerpt for novice programmers.

//Good for a standalone tests
static void matchesTest(final String pattern, final String text) {
try {
//To check if a regular expression pattern matches a text

boolean matches = Pattern.matches(pattern, text);

System.out.printf("%s %s\n", pattern, matches);

} catch (Exception exc) {
System.out.println("not valid");
}
}

If you require further information for Assessment Software, please visit the following site Online Test Software:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

BIS
BIS

Written by BIS

Specialist in Cloud Native development

No responses yet

Write a response