Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Regex or String Algoritham

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Regex or String Algoritham

    Hello please,
    Appreciate your help here.
    I have a field string that wants to find if that exists between two range strings on character basis.

    Ex:

    String lower boundary : "ABD"
    String upper boundary : "ALGKP"
    field String : "ABE"

    Now the field string "ABE" exists between "ABD" and "ALGKP".
    Here the comparison is char-by-char. i.e
    A is b/w A & A, true
    B is b/w B and L, true
    E is b/w D and G, true
    So finally returns true.

    Another example:

    For the same above boundaries, if the field string is "ABC", it should return false since C not b/w D & P.
    For the same above boundaries, if the field string is "AB", it should return true.

    Thanks
    Dileep


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Regex or String Algoritham

    Hello and welcome to the forums.

    What are you stuck on? Have you attempted any code?

    On the subject of RegEx, please read - http://www.javaprogrammingforums.com...explained.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Regex or String Algoritham

    Are trying to write your own "regex" engine? If you are, I would recommend reading on finite state automata/finite state machines. While the deterministic state machines are really the only ones that can actually be handled by a computer, you may want to also read about non-deterministic state machines as well as these are much easier for people to design and can be converted into a deterministic state machine with some clever thinking.

  4. #4
    Forum VIP
    Join Date
    Jun 2011
    Posts
    317
    My Mood
    Bored
    Thanks
    47
    Thanked 89 Times in 74 Posts
    Blog Entries
    4

    Default Re: Regex or String Algoritham

    One of the tricks I like to use with these kind of String computation problems is to treat the characters in the string like numbers. Try using charAt then casting the char into an int. The value of the int will be in the range 65..90 for 'A' to 'Z' (case sensitive). This will reduce your problem to a simple integer range check.

  5. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Regex or String Algoritham

    1. Why revive a thread that is several months old?

    2. Why not just make 2 calls to compareTo? Even if you had to write the code yourself, why fanny about converting chars to ints?
    System.out.println('a' < 'b');
    Improving the world one idiot at a time!

Similar Threads

  1. Need help with Regex
    By snytkine in forum Java Theory & Questions
    Replies: 4
    Last Post: October 12th, 2010, 07:30 AM
  2. Need help with regEx
    By ptabatt in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 14th, 2010, 11:17 AM
  3. Please help required with Java Algoritham Programming
    By simply_stunning79 in forum Algorithms & Recursion
    Replies: 1
    Last Post: February 22nd, 2010, 07:42 PM
  4. Possible regex problem?
    By Bill_H in forum What's Wrong With My Code?
    Replies: 6
    Last Post: October 25th, 2009, 01:36 AM
  5. Regex Question
    By igniteflow in forum Java SE APIs
    Replies: 1
    Last Post: August 28th, 2009, 11:46 AM