dimanche 24 mai 2020

How to extract a data from text file using Regex expressions in JAVA?

I have text file as follows .This is not a XML file (you can Imagine as testscripts),text within the < > is a test id's [Refer the image for textfile]

For Text File click here

I want to extract the test ID's from the testscripts using regex expression.

Please help me in writing regex expression for this.

I wrote a following java code.

public static void fillIdsHashSet(String line,HashSet<String> container){

    Pattern p = Pattern.compile("           ");//Regex Expression
    Matcher m = p.matcher(line);

    while(m.find()) {
        container.add(m.group(1));
    }

}

Aucun commentaire:

Enregistrer un commentaire