Java: Java Programming For Beginners a simple Start To Java Programming (Written By a software Engineer)


Download 0.82 Mb.
Pdf ko'rish
bet45/95
Sana09.01.2022
Hajmi0.82 Mb.
#261112
1   ...   41   42   43   44   45   46   47   48   ...   95
Bog'liq
Java Programming For Beginners - A Simple Start to Java Programming ( PDFDrive )

The begin and end Methods:
Taking after is the sample that tallies the quantity of times the statement “felines” shows
up in the data string:
import java.util.regex.pattern;
import java.util.regex.matcher;
public class Regexmatches {
private static last String INPUT = “feline cattie feline”;
private static last String REGEX = “\bcat\b”;
public static void principle( String args[] ){
Pattern myp = Pattern.compile(regex);
Matcher mym = myp.matcher(input);
int checkval = 0;
while(mym.find()) {


count++;
System.out.println(“match number “+count);
System.out.println(“start(): “+mym.start());
System.out.println(“end(): “+mym.end());
}
}
You can see that this sample uses word limits to guarantee that the letters “c” “a” “t” are
not only a substring in a more extended word. It likewise provides for some helpful data
about where in the information string the match has happened. The begin technique gives
back  where  its  due  record  of  the  subsequence  caught  by  the  given  group  amid  the  past
match operation, and end furnishes a proportional payback of the last character matched,
in addition to one.

Download 0.82 Mb.

Do'stlaringiz bilan baham:
1   ...   41   42   43   44   45   46   47   48   ...   95




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling