Skip to content

Instantly share code, notes, and snippets.

@Nazmul56
Created January 16, 2018 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nazmul56/3cf75f9b8354d722893549109313d62f to your computer and use it in GitHub Desktop.
Save Nazmul56/3cf75f9b8354d722893549109313d62f to your computer and use it in GitHub Desktop.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexMatches {
public static void main( String args[] ) {
// String to be scanned to find the pattern.
String line = "a=sendrecv a=rtcp-mux a=rtcp-rsize a=rtpmap:96 VP8 90000 a=rtcp-fb:96 goog-remb a=rtpmap:96 VP8 90001 a=rtpmap:96 VP8 90002";
String codec = "VP8";
String pattern = "a=rtpmap:(\\d+) " + codec + " (\\d+)";//+[\r]?$";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(line);
while(m.find()){
System.out.println("Found value: " + m.group(0) );
System.out.println("Found value: " + m.group(1) );
System.out.println("Found value: " + m.group(2) );
}
/*
if (m.find( )) {
System.out.println("Found value: " + m.group(0) );
System.out.println("Found value: " + m.group(1) );
System.out.println("Found value: " + m.group(2) );
}else {
System.out.println("NO MATCH OR END");
}
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment