Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) {
        String testString = " weight 600 KG AND HEIGHT 84900 CM";
        Pattern pattern = Pattern.compile("(?<=HEIGHT)\\s*([0-9]+)\\s*(?=CM)");
        Matcher matcher = pattern.matcher(testString);
        while (matcher.find()) {
            System.out.println("Height: '" + matcher.group(1) + "'");
        }
    }
}