File tree Expand file tree Collapse file tree
BasicJava/RegexDemo_logical_operatior_to Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" path =" src" />
4+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
5+ <classpathentry kind =" output" path =" bin" />
6+ </classpath >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >RegexDemo</name >
4+ <comment ></comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.jdt.core.javabuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ </buildSpec >
14+ <natures >
15+ <nature >org.eclipse.jdt.core.javanature</nature >
16+ </natures >
17+ </projectDescription >
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode =enabled
3+ org.eclipse.jdt.core.compiler.codegen.targetPlatform =1.8
4+ org.eclipse.jdt.core.compiler.codegen.unusedLocal =preserve
5+ org.eclipse.jdt.core.compiler.compliance =1.8
6+ org.eclipse.jdt.core.compiler.debug.lineNumber =generate
7+ org.eclipse.jdt.core.compiler.debug.localVariable =generate
8+ org.eclipse.jdt.core.compiler.debug.sourceFile =generate
9+ org.eclipse.jdt.core.compiler.problem.assertIdentifier =error
10+ org.eclipse.jdt.core.compiler.problem.enumIdentifier =error
11+ org.eclipse.jdt.core.compiler.source =1.8
Original file line number Diff line number Diff line change 1+ import java .util .regex .Matcher ;
2+ import java .util .regex .Pattern ;
3+
4+ /**
5+ *
6+ * Logical Operators
7+ *
8+ */
9+ public class RegexDemo1
10+ {
11+
12+ public static void main (String [] args )
13+ {
14+ /*
15+ * The Logical Operator XY matches the X followed by Y.
16+ */
17+ Pattern pattern = Pattern .compile ("to" );
18+ Matcher matcher = pattern .matcher ("Welcome to India" );
19+
20+ while (matcher .find ())
21+ {
22+ System .out .println (matcher .group () + ", Match String start(): "
23+ + matcher .start ());
24+ }
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1+ import java .util .regex .Matcher ;
2+ import java .util .regex .Pattern ;
3+
4+ /**
5+ *
6+ * Logical Operators
7+ *
8+ */
9+ public class RegexDemo2
10+ {
11+
12+ public static void main (String [] args )
13+ {
14+ /*
15+ * The Logical Operator X|Y matches the X or Y.
16+ */
17+ Pattern pattern = Pattern .compile ("t|o" );
18+ Matcher matcher = pattern .matcher ("Welcome to India" );
19+
20+ while (matcher .find ())
21+ {
22+ System .out .println (matcher .group () + ", Match String start(): "
23+ + matcher .start ());
24+ }
25+ }
26+
27+ }
Original file line number Diff line number Diff line change 1+ to, Match String start(): 8
Original file line number Diff line number Diff line change 1+ o, Match String start(): 4
2+ t, Match String start(): 8
3+ o, Match String start(): 9
You can’t perform that action at this time.
0 commit comments