Created
January 16, 2018 08:53
-
-
Save Nazmul56/3cf75f9b8354d722893549109313d62f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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