Regular expression to match incremental or consecutive digits

I need to process a string containing all digits to ensure that it does not contain either
(a) a group of 5 or more consecutive identical digits eg. 11111
(b) a group of 5 or more incremental/decremental digits eg 12345, 98765
Also, is there a processing difference between the reluctant and greedy qualifiers?
Case (a) seems to be easy:
Pattern pattern = Pattern.compile("[0-9]{5,}?");but what about (b) ? From the documentation it seems that using capturing groups might be helpful, but they are confusing me.
Finally how do I merge multiple pattern matching strings into one overall regular expression so I can make one pass on the input to see whether it is valid or not?
Thanks
Chris

give this code a try
public class Test {
     static boolean check(String str) {
          loop : for (int x = 0, y; x < str.length() - 4; x += y) {
               y = 1;
                 int dif = (str.charAt(x+y) - str.charAt(x)); //assuming you don't whant 90123
                 if (dif >= -1 && dif <= 1) {
                    for (; y < 4; y++) {
                         if ((str.charAt(x+y+1) - str.charAt(x+y)) != dif) {
                              continue loop;
                    return true;
          return false;
     public static void main(String[] args) {
          System.out.println(check(args[0]));
}

Similar Messages

  • "Match Regular Expression" and "Match Pattern" vi's behave differently

    Hi,
    I have a simple string matching need and by experimenting found that the "Match Regular Expression" and "Match Pattern" vi's behave somewhat differently. I'd assume that the regular expression inputs on both would behave the same. A difference I've discovered is that the "|" character (the "vertical bar" character, commonly used as an "or" operator) is recognized as such in the Match Regular Expression vi, but not in the Match Pattern vi (where it is taken literally). Furthermore, I cannot find any documentation in Help (on-line or in LabVIEW) about the "|" character usage in regular expressions. Is this documented anywhere?
    For example, suppose I want to match any of the following 4 words: "The" or "quick" or "brown" or "fox". The regular expression "The|quick|brown|fox" (without the quotes) works for the Match Regular Expression vi but not the Match Pattern vi. Below is a picture of the block diagram and the front panel results:
    The Help says that the Match Regular Expression vi performs somewhat slower than the Match Pattern vi, so I started with the latter. But since it doesn't work for me, I'll use the former. But does anyone have any idea of the speed difference? I'd assume it is negligible in such a simple example.
    Thanks!
    Solved!
    Go to Solution.

    Yep-
    You hit a point that's frustrated me a time or two as well (and incidentally, caused some hair-pulling that I can ill afford)
    The hint is in the help file:
    for Match regular expression "The Match Regular Expression function gives you more options for matching
    strings but performs more slowly than the Match Pattern function....Use regular
    expressions in this function to refine searches....
    Characters to Find
    Regular Expression
    VOLTS
    VOLTS
    A plus sign or a minus sign
    [+-]
    A sequence of one or more digits
    [0-9]+
    Zero or more spaces
    \s* or * (that is, a space followed by an asterisk)
    One or more spaces, tabs, new lines, or carriage returns
    [\t \r \n \s]+
    One or more characters other than digits
    [^0-9]+
    The word Level only if it
    appears at the beginning of the string
    ^Level
    The word Volts only if it
    appears at the end of the string
    Volts$
    The longest string within parentheses
    The first string within parentheses but not containing any
    parentheses within it
    \([^()]*\)
    A left bracket
    A right bracket
    cat, cag, cot, cog, dat, dag, dot, and dag
    [cd][ao][tg]
    cat or dog
    cat|dog
    dog, cat
    dog, cat cat dog,cat
    cat cat dog, and so on
    ((cat )*dog)
    One or more of the letter a
    followed by a space and the same number of the letter a, that is, a a, aa aa, aaa aaa, and so
    on
    (a+) \1
    For Match Pattern "This function is similar to the Search and Replace
    Pattern VI. The Match Pattern function gives you fewer options for matching
    strings but performs more quickly than the Match Regular Expression
    function. For example, the Match Pattern function does not support the
    parenthesis or vertical bar (|) characters.
    Characters to Find
    Regular Expression
    VOLTS
    VOLTS
    All uppercase and lowercase versions of volts, that is, VOLTS, Volts, volts, and so on
    [Vv][Oo][Ll][Tt][Ss]
    A space, a plus sign, or a minus sign
    [+-]
    A sequence of one or more digits
    [0-9]+
    Zero or more spaces
    \s* or * (that is, a space followed by an asterisk)
    One or more spaces, tabs, new lines, or carriage returns
    [\t \r \n \s]+
    One or more characters other than digits
    [~0-9]+
    The word Level only if it begins
    at the offset position in the string
    ^Level
    The word Volts only if it
    appears at the end of the string
    Volts$
    The longest string within parentheses
    The longest string within parentheses but not containing any
    parentheses within it
    ([~()]*)
    A left bracket
    A right bracket
    cat, dog, cot, dot, cog, and so on.
    [cd][ao][tg]
    Frustrating- but still managable.
    Jeff

  • How to form a regular expression for matching the xml tag?

    hi i wanted to find the and match the xml tag for that i required to write the regex.
    for exmple i have a string[] str={"<data>abc</data>"};
    i want this string has to be splitted like this <data>, abc and </data>. so that i can read the splitted string value.
    the above is for a small excercise but the tagname and value can be of combination of chars/digits/spl symbols like wise.
    so please help me to write the regular expression for the above requirement

    your suggestion is most appreciable if u can give the startup like how to do this. which parser is to be used and stuff like that

  • Urgent!!! Problem in regular expression for matching braces

    Hi,
    For the example below, can I write a regular expression to store getting key, value pairs.
    example: ((abc def) (ghi jkl) (a ((b c) (d e))) (mno pqr) (a ((abc def))))
    in the above example
    abc is key & def is value
    ghi is key & jkl is value
    a is key & ((b c) (d e)) is value
    and so on.
    can anybody pls help me in resolving this problem using regular expressions...
    Thanks in advance

    "((key1 value1) (key2 value2) (key3 ((key4 value4)
    (key5 value5))) (key6 value6) (key7 ((key8 value8)
    (key9 value9))))"
    I want to write a regular expression in java to parse
    the above string and store the result in hash table
    as below
    key1 value1
    key2 value2
    key3 ((key4 value4) (key5 value5))
    key4 value4
    key5 value5
    key6 value6
    key7 ((key8 value8) (key9 value9))
    key8 value8
    key9 value9
    please let me know, if it is not possible with
    regular expressions the effective way of solving itYes, it is possible with a recursive regular expression.
    Unfortunately Java does not provide a recursive regular expression construct.
    $_ = "((key1 value1) (key2 value2) (key3 ((key4 value4) (key5 value5))) (key6 value6) (key7 ((key8 value8) (key9 value9))))";
    my $paren;
       $paren = qr/
               [^()]+  # Not parens
             |
               (??{ $paren })  # Another balanced group (not interpolated yet)
        /x;
    my $r = qr/^(.*?)\((\w+?) (\w+?|(??{$paren}))\)\s*(.*?)$/;
    while ($_) {
         match()
    # operates on $_
    sub match {
         my @v;
         @v = m/$r/;
         if (defined $v[3]) {
              $_ = $v[2];
              while (/\(/) {
                   match();
              print "\"",$v[1],"\" \"",$v[2],"\"";
              $_ = $v[0].$v[3];
         else { $_ = ""; }
    C:\usr\schodtt\src\java\forum\n00b\regex>perl recurse.pl
    "key1" "value1"
    "key2" "value2"
    "key4" "value4"
    "key5" "value5"
    "key3" "((key4 value4) (key5 value5))"
    "key6" "value6"
    "key8" "value8"
    "key9" "value9"
    "key7" "((key8 value8) (key9 value9))"
    C:\usr\schodtt\src\java\forum\n00b\regex>

  • Regular expressions: find files with exactly 'n' digits in a row

    Hi there,
    I want to filter files that contain only a fixed number of digits, but not more (at least not in after the digits).
    For example, I have
    01.mp3
    02.mp3
    test10.txt
    test000110101010.txt
    04.flac
    and for n=2 I want to get all files except 'test000110101010.txt'.
    The following is not working, and I'm a total newb regarding regular expressions
    ls -l | grep '^-' | awk '{print $9}' | grep '([0-9]\{2\})[^0-9]\{2\}'
    Thanks for help.
    Regards,
    drm

    Thanks!
    I wrote a python script to scan e.g. a music folder for missing files and needed to extract the file numbers from the files to get the "highest" number.
    You can get it from here: http://pastebin.com/Sg9yDHiw (Python3, expires in 1 month)
    Regards,
    drm
    Edit: found a bug
    Last edited by drm00 (2011-02-04 13:57:43)

  • Regular Expression for Match Pattern (string) Function

    I need to find a variable length string enclosed by brackets and
    within a string. Can't seem to get the regular expression right for
    the Match Pattern function. I'm able to get the job done using the
    Token function, but it's not as slick or tight as I'd like. Does
    anybody out there have the expression for this?

    Jean-Pierre Drolet wrote in message news:<[email protected]>...
    > The regular expression is "\[[~\]]*\]" which means:
    > look for a bracket "\[" (\ is the escape char)
    > followed by a string not containing a closing bracket "[~\]]*"
    > followed by a closing bracket "\]". The match string include the
    > brackets
    >
    > You can also read "Scan from String" with the following format:
    > "%[^\[]\[%[^\[\]]" and read the 2nd output. The brackets are removed
    > from the scanned string.
    Thanks, Jean_Pierre
    I did some more experimenting after posting and found that \[.*\] also
    works with the match pattern function. Thanks for your input.
    sm

  • Regular expressions for matching file path

    Could someone give me idea that how can i compare a fixed path, with the paths user gives using regular expressions?
    My fixed path is : src\com\sample\demo\work\gui\.**
    and user may give like src\com\sample\demo\work\gui\test.jsp, src\com\sample\demo\work\gui\init.jsp etc.
    Any ideas are appreciated and thanks in advance.

    ...and if you insist on using regexes, you'll have to double-escape the backslashes: if ( userString.matches("src\\\\com\\\\sample\\\\demo\\\\work\\\\gui\\\\.*") ) { Whether you use regexes or not, you'll save yourself a lot of hassle by converting all backslashes to forward slashes before you do anything with the strings: userString = userString.replace('\\', '/');
    if ( userString.matches("src/com/sample/demo/work/gui/.*") ) {
    // or...
    if ( userString.startsWith("src/com/sample/demo/work/gui/") ) {

  • Regular Expression for match pattern

    Hi guys, I need some help.
    In one part of my test system, I give to the program a sequence of temperatures, which are numbers separated by a comma. Due to a possible error, the user can  forget the coma, and the program gets unexpected values.
    For example, "20, 70, -10" is a right value, whereas "20 70, -10" would be a wrong one.
    Which regular expression will detect this comma absence?
    Thanx in advance.

    OK, makes it more difficult (and more fun )
    My original version failed also when the space was forgotten.  DOH!
    Try this version.  It get's complicated cause the scan from string likes ignoring spaces... So we change the spaces
    Hope this helps
    Shane.
    PS The ideas given by others are still a better solution, but if you're stuck........
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
    Attachments:
    Check input string with commas(array).vi ‏39 KB

  • Regular Expressions (Pattern/Matcher) --- Help

    Hi,
    I have an regex i.e. Pattern.compile("([0-9])D([0-9])'?(?:([0-9]+)\")?([NSEW])").{code}
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507
    According to the bug report, they have said that are many different regex that can trigger the stack overflow....even though the length of my input is not as long as the one posted on the bug report.
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    I missed the '+' in my original regex Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])"){code}.
    I have also tried {code} Pattern.compile("(\\d+)D(\\d+)'?(?:(\\d+)\")?([NSEW])");And, the other 2 expressions as suggested by you.
    The problem happens when Durham Lat=”35D52’N” Lon=”78D47’W value is selected from a Jtree(the values are parsed from a xml file to the tree - the xml file has a bout 800 longitude/latitude elements for different cities in the US). It does not happen for other values and If I increment the degree or min by, then the expression works. I am not sure how else i could re-write this exp.
    Below is the snippet of the xml file:
    <State name="NORTH CAROLINA">
                <City name="Asheville AP"     Lat="35D26'N"     Lon="82D32'W"/>
                <City name="Charlotte AP"     Lat="35D13'N"     Lon="80D56'W"/>
                <City name="Durham"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Elizabeth City AP"     Lat="36D16'N"     Lon="76D11'W"/>
                <City name="Fayetteville, Pope AFB" Lat="35D10'N"     Lon="79D01'W"/>
                <City name="Goldsboro,Seymour-Johnson"     Lat="35D20'N"     Lon="77D58'W"/>
                <City name="Greensboro AP (S)"     Lat="36D05'N"     Lon="79D57'W"/>
                <City name="Greenville"     Lat="35D37'N"     Lon="77D25'W"/>
                <City name="Henderson"     Lat="36D22'N"     Lon="78D25'W"/>
                <City name="Hickory"     Lat="35D45'N"     Lon="81D23'W"/>
                <City name="Jacksonville"     Lat="34D50'N"     Lon="77D37'W"/>
                <City name="Lumberton"     Lat="34D37'N"     Lon="79D04'W"/>
                <City name="New Bern AP"     Lat="35D05'N"     Lon="77D03'W"/>
                <City name="Raleigh/Durham AP (S)"     Lat="35D52'N"     Lon="78D47'W"/>
                <City name="Rocky Mount"     Lat="35D58'N"     Lon="77D48'W"/>
                <City name="Wilmington AP"     Lat="34D16'N"     Lon="77D55'W"/>
                <City name="Winston-Salem AP"     Lat="36D08'N"     Lon="80D13'W"/>
            </State>
    public final class GeoLine {
        /* Enum for the possible directions of longitude and latitude*/
        public enum Direction {
            N, S, E, W;
            public boolean isLongitude() {
                return (this == E || this == W);
            public boolean isLatitude() {
                return (this == N || this == S);
            public Direction getCanonicalDirection() {
                if (this == S) {
                    return Direction.N;
                } else if (this == W) {
                    return Direction.E;
                } else {
                    return this;
        private final int degree;
        private final int minute;
        private final int second;
        private final Direction dir;
        /* Recognizes longitude and latitude values that has degrees, minutes and seconds i.e. "45D15'34"N
        * or "45D1534"N. The single-quotes for the minutes is optional. And, for the moment we do not support seconds
        * validation although ilog library returns the longitude/latitude with second when NEs and Sub-networks are
        * dragged and dropped on the map.*/
    private static final Pattern PATTERN = Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])");
        public GeoLine(int degree, int minute, Direction dir) {
            this(degree, minute, 0, dir);
        public GeoLine(int degree, int minute, int second, Direction dir) {
            Log.logInfo(getClass().getSimpleName(), "PAU degree: " + degree + " minute: " + minute + " second: " + second + " direction: " +  dir);
            verifyLongitudeLatitude(degree, dir);
            verifyMinute(degree, minute, dir);   
            this.degree = degree;
            this.minute = minute;
            this.second = second;
            if (this.degree == 0 && this.minute == 0 && this.second == 0) {
                this.dir = dir.getCanonicalDirection();
            } else {
                this.dir = dir;
        public Direction getDirection() {
            return dir;
        public int getMinute() {
            return minute;
        public int getDegree() {
            return degree;
        public int getSecond() {
            return second;
        public static GeoLine parseLine(String location) {
            * Matcher class will throw java.lang.NullPointerException if a null location
            *  is passed, null location validation is not needed.
            Matcher m = PATTERN.matcher(location);
            if(m.matches()) {
                int deg;
                int min;
                int second;
                Direction direction;
                deg = Integer.parseInt(m.group(1));
                min = Integer.parseInt(m.group(2));
                if (m.group(3) == null) {
                    second = 0;
                } else {
                    second = Integer.parseInt(m.group(3));
                direction = Direction.valueOf(m.group(4));
                return new GeoLine(deg, min, second, direction);
            } else {
                throw new IllegalArgumentException("Invalid location value. Expected format XXDXX'XX\"[NSEW] " + location);
        private void verifyMinute(int deg, int min, Direction direction) {
            /* This validation is to make sure that minute does not exceed 0 if maximum value for latitude == 90
            * or longitude == 180 is specified */
            int maxDeg = direction.isLatitude() ? 90 : 180;
            if(min < 0 || min > 59) {
               throw new NumberFormatException("Minutes is out of range. Value should be less than 60: " + min);
            if (deg == maxDeg && min > 0) {
                throw new NumberFormatException("Degree value " + deg + "D" + direction + " cannot have minute exceeding 0: " + min);
        private void verifyLongitudeLatitude(int valDeg, Direction valDir) {
               int max = valDir.isLatitude() ? 90 : 180;
               if(valDeg < 0 || valDeg > max) {
                    throw new NumberFormatException("Degree " + valDeg + valDir + " is invalid");
        public final boolean isLongitude() {
            return dir.isLongitude();
        public final boolean isLatitude() {
            return dir.isLatitude();
        @Override
        public final String toString(){
            if(minute < 10){
                return degree + "D0" + minute + dir;
            } else {
                return degree + "D" + minute + dir;
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof GeoLine) {
                GeoLine other = (GeoLine) obj;          
                    return (this.degree == other.degree && this.minute == other.minute && this.second == other.second && this.dir == other.dir);
            return false;
        @Override
        public int hashCode() {
            int result = 17;
            result = result * 37 + degree;
            result = result * 37 + minute;
            result = result * 37 + second;
            result = result * 37 + dir.hashCode();
            return result;
    }Thank you again.

  • Regular expression question - match a template

    Hello All!
    I've put regex patterns to simple use b4, but this one I'm finding a bit of a challenge.
    I need to match lines to the following template:
    "9############ ###9,99 XXXXX####9,99 #9"In this template 9s mean digits, Xs mean alphanum characters and the #s mean optional digits.
    For example the following strings must mutch the above pattern:
    1. "123             18,10 abcde    9,99  1"
    2. "1234567890123 1000,99 CCCCC  260,99  2"This is the regex I came up with so far.
    "^[ \\d]{13}? [ \\d]{3}?\\d,\\d\\d .{5}?[ \\d]{4}\\d,\\d\\d [ \\d]\\d$"The problem with it of course is that it will match a string like:
    1. "9            9  9 ,99 abcde  9 9,99  1"Basically, the question is whether it is possible to ensure that when the optional digits are
    not present, they have the required spaces in their positions.
    Any help is much appreciated.
    P.s. the reason I am trying to use regex instead of splitting the string and validating the tokens
    separately is because I have a number of such templates to validate lines against, and each template signals a particular line type. :) Basically I need to decide what type of line is it I just read from a file...
    Thnx.

    First of all, isn't the first digit mandatory?
    That would mean that the first part of your regex should be:"^\\d"followed by 12 characters that can be either ' ' or any digit:"^\\d[ \\d]{12}"followed by space, three spaces or digits and a digit"^\\d[ \\d]{12} [ \\d]{3}\\d"comma, two digits, space, five alphanums"^\\d[ \\d]{12} [ \\d]{3}\\d,\\d{2} [\\w[^_]]{5}"4 space or digit, digit, comma, 2 digits"^\\d[ \\d]{12} [ \\d]{3}\\d,\\d{2} [\\w[^_]]{5}[ \\d]{4}\\d,\\d{2}"space, space or digit, digit, the end"^\\d[ \\d]{12} [ \\d]{3}\\d,\\d{2} [\\w[^_]]{5}[ \\d]{4}\\d,\\d{2} [ \\d]\\d$"And please note that the string you provided"9            9  9 ,99 abcde  9 9,99  1"is not supposed to match but the string"9                9,99 abcde    9,99  9"will.

  • How can I use regular expression to match this rule

    I have a String ,value is "<a>1</a><a>2</a><a>3</a>",and want to match other String like "<a>1</a><a>8</a>",if the one of the first string(like "<a>1</a>") will occur in the second string,then will return true.but I don't know how to write the regular expresstion.
    Thx

    Fine fine. :P
    I was a little bored, so here's some code that uses Strings and a StringBuffer (though you could use a String in place of the StringBuffer). Is this perhaps better? :)
              String testMain = "<a>1</a><ab>2</ab><ab>3</ab>";
              String test = "<ab>1</ab><ab>3</ab>";
              String open = "<ab>";
              String close = "</ab>";
              StringBuffer search = new StringBuffer();
              String checkString = null;
              int lastCheck = 0;
              int start = 0;
              int finish = 0;
              boolean done = false;
              while (!done) {
                   start = test.indexOf(open);
                   finish = test.indexOf(close);
                   if ((start == -1) || (finish == -1)) {
                        System.out.println("No more tags to search for.");
                        done = true;
                   else {
                        checkString = test.substring((start + open.length()), finish);
                        search = new StringBuffer();
                        search.append(open);
                        search.append(checkString);
                        search.append(close);
                        if (testMain.indexOf(search.toString()) != -1) {
                             System.out.println("Found value: " + checkString);
                        test = test.substring(finish + close.length());
    Resulting output:
    Found value: 3
    No more tags to search for.
    -G

  • Regular Expressions (Pattern/Matcher)

    Hi,
    I have an regex i.e. *Pattern.compile("([0-9]+)D([0-9]+)'?(?:([0-9]+)\")?([NSEW])").*
    It has to exactly match the input e.g *45D15'34"N*
    I need to retrieve the values based on grouping.
    Group1 = 45 (degree value)
    Group2 = 15 (minutes value)
    Group3 = 34 (seconds value) ----> this is a non-capturing group
    Group4 = N (directions)
    The regex works fine for most of longitude/latitude value but I get a StackOverFlow for some. There is a known bug on this [http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5050507]
    I was wondering if anyone could suggest a different way of writing the regex above to avoid the stack over flow.
    Thank you in advance

    cienaP wrote:
    Hi,
    I have reposted the topic. Thank you for letting me know, this is my first time.You didn't need to create a [new thread|http://forums.sun.com/thread.jspa?threadID=5416548&messageID=10865976#10865976]! You could just have posted a response containing your regex. I shall lock this thread.

  • Regular Expressions / String Match

    Hi Everyone,
    thankx for reading this
    I'm programing a oracle form which at one part read's the full path into a file (a text file) and place's it on a VARCHAR2 field. This is the path into the file and not the file data.
    I would like to match this string (the file path) to a another one (in order to know if the file name respect some rules). This is a very easy thing to do under Perl / PHP and other languages. But how can i do this under PL/SQL ?
    I have search but failed to find any clue.
    Any pointers would be great, or a small example
    Thankx Stay Happy
    Miguel Angelo

    Hi,
    you can use INSTR and SUBSTR for String comparison
    INSTR(char1,char2) shows you the first occurence of char2 in char1
    INSTR(char1,char2,n,m)
    shows the m'th occurence of char2 in char1 starting on n
    Frank

  • Regular Expression / String matching other than equality check with groovy.

    I want to have a string comparison operation using a groovy expression.
    Not an equality check, but something like
    #{variableName like 'IC%'?'true':'false'}
    I saw some operators like
    #{bindings.gradeName.inputValue =~ 'IC'?true:false}
    But it doesnt seem to be working.
    Is it possible with groovy?
    Arun

    Hi
    nything will do.
    And not using bean.
    This expression has to added in an AMX page (ADF Mobile
    It depends on where you want to execute this. Groovy in a validation script would be different to EL in a page as they would be in different stages in the lifecycle.
    Now for ADF MObile this may be different, I dont know.'
    If its to be part of a validation then you can call the source methods in groovy and do the comparison.
    from a validator for instance:
    source.getGradeName() returns the grade name before commiting.
    String enteredgrade = source.getGradeName();
    if (enteredgrade.index(0).equals('I') and enteredgrade(1).equals('C'){
    do what you want here. i.e. return true or false etc.
    el in a page would look entirly different but you can implement this same functionality in a bean, access it via the accessors and then return true or false.
    if you are already using EL and you managed to link your page with JSTL, you will have to define the access variable in the header section inorder to access it and then use "startswith", though I havent tried it this way.

  • Regular expression, Pattern.matcher() method

    Pattern.matcher() method start finding a new match from the end of the previous matcher.
    Can Pattern.matcher() method start finding a new match from the second letter of the previous match?
    For example, this piece of code will give a result as :
    find 1 --- 3
    find 4 --- 6
    +++++++++++++++++++++++++++++++++++++++++++++++++++
              Pattern pattern = Pattern.compile("aaa");
              Matcher matcher = pattern.matcher("aaaaaaa");
              while(matcher.find())
                   int from = matcher.start() + 1;
                   int to = matcher.end();
                   System.out.println("find " + from + " --- " + to);
    ++++++++++++++++++++++++++++++++++++++++++++++++++++
    How can I change the code so the programme can give a result as:
    find 1 --- 3
    find 2 --- 4
    find 3 --- 5
    find 4 --- 6
    find 5 --- 7
    Thanks very much in advance.

    Check out the API there are Two find methods
    public boolean find() - This method starts at the beginning of the input sequence or, if a previous invocation of the method was successful and the matcher has not since been reset, at the first character not matched by the previous match.
    public boolean find(int start) Resets this matcher and then attempts to find the next subsequence of the input sequence that matches the pattern, starting at the specified index.
    so you could do it something like this:
    int startIndex = 0
    while (matcher.find(startIndex)){
      int from = matcher.start() + 1;
      int to = matcher.end();
      System.out.println("find " + from + " --- " + to);
      startIndex = ?????
    }

Maybe you are looking for

  • Iphoto 6 and my HD space ! It's eating it all up !?

    Hello. I am trying to free up space on my MBPro as whenever I get down to 5GB HD space it grinds to a slow pace of a glacier. I think the problem lies with Iphoto 6.0.6 and the 13000 photos I had, and that IPhoto always duplicates ORIGINAL photos int

  • How to restrict fileAdapter??

    Hi All, I am using JDev 10.1.3.3 and SOA 10.1.3.3. I have 100 files in a folder. I need to read the filenames and directory. I have done those things by using InboundHeader.wsdl. Now the requirement is I need to read only first 10 files. How can I st

  • Error license file exception (check the logfile for details). Features Is Locked To A Different host (-9,30035)

    Plz Help note: the instalation is over ESX and VMware 

  • Hunt Groups and Voicemail

    Was not sure if this was the right group to post these questions. I believe that these will be super easy for this group, and I want to double check my thinking against you guys. So, here they are. If we elect to use a BROADCAST type of hunt group in

  • Corrupt RD3 Files in COLOR

    Hi, When I send my FCP sequence (media linked to RD3 files) to Color, I get corrupt files. I am using Color 1.0.4 and FCP 6.0.6. I have identified the corrupt files to come from the same 12 media clips. I tried re-linking the clips again, but it did