Lookbehind
Lookbehind is just like Lookahead. They only assert whether immediate portion behind a given input string’s current portion is suitable for a match or not. We can make our own lookbehinds with the lookbehind operator (?<=).
Lookbehind Before the Match Examples
Lookbehind with Lookahead
Lookbehind After the Match Examples
Program
import java.util.regex.Pattern; import java.util.regex.Matcher; public class Javaapp { public static void main(String[] args) { Pattern pat = Pattern.compile("\\d+(?<=INR\\d{3})"); Matcher mat = pat.matcher("USD100 INR200 EUR300 INR400 AED500"); while(mat.find()) { System.out.println("INR = "+mat.group()); } } }