FileDocCategorySizeDatePackage
REsubstr.javaAPI DocExample613Sun Feb 08 21:33:42 GMT 2004None

REsubstr

public class REsubstr extends Object
REsubstr -- demonstrate RE Match -> String.substring()
author
Ian F. Darwin, http://www.darwinsys.com/
version
$Id: REsubstr.java,v 1.3 2004/02/09 03:33:42 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)

		//+
		String patt = "Q[^u]\\d+\\.";
		Pattern r = Pattern.compile(patt);
		String line = "Order QT300. Now!";
		Matcher m = r.matcher(line);
		if (m.find()) {
			System.out.println(patt + " matches \"" +
				line.substring(m.start(0), m.end(0)) +
				"\" in \"" + line + "\"");
		} else {
			System.out.println("NO MATCH");
		}