Youtube Channel

Pattern Macthing and Auto Form fill -Up

Hopefully you have come accross some jobs portal where you upload your resume or cv and automatically data from your resume get filled in the form .
Lets see how it can be done through Pattern matching in java.

It can be achieved through file handling where we will undergone the reading data from file validation with the desired pattern and the last thing to fill this data to the forms.

E.g: Mobile no extraction from c.v

package com.pack.fileHandling;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ReadFile {
    public static void main(String[] args) throws Exception{

        String mypattern="[7-9][0-9]{9}";  //desired pattern for mobile no
        Pattern p=Pattern.compile(mypattern);
        BufferedReader br=new BufferedReader(new FileReader("d:\\mob.txt")); // Opening the file or remsume
        String line=br.readLine(); //Reading line by line
        while(line!=null)
        {
            Matcher m=p.matcher(line); //Matching with pattern
            while(m.find())
            {
                  // if match found so set it to the form or print it
                System.out.println(m.group());
            }
            line=br.readLine();
        }
        br.close();
    }

}
Next PostNewer Post Previous PostOlder Post Home