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 3 of 3

Thread: Representing the return key in a regular expression

  1. #1
    Member
    Join Date
    Jul 2013
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Representing the return key in a regular expression

    Quick question that my last program made me want to ask. I found another solution that didn't require me to do this for the program, but it got me curious: How do you represent a return key in a regular expression?

    Let's say you want to hold execution pending a return key press (which is what I was doing). One way to do that would be to rig a scanner on System.in using a delimiter pattern that says to accept only return characters. So for instance:

    Pattern p = Pattern.compile("//Regular expression goes here.");

    What character would one use in that regular expression for representing the return key?

    Thanks as always,
    -summit45


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 262 Times in 231 Posts

    Default Re: Representing the return key in a regular expression

    Quote Originally Posted by summit45 View Post
    What character would one use in that regular expression for representing the return key?
    Excellent question for a search engine.
    At the risk of sounding rude, we have better things to do with our time than your research.

  3. #3
    Member
    Join Date
    Jul 2013
    Posts
    47
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Representing the return key in a regular expression

    Quote Originally Posted by jps View Post
    Excellent question for a search engine.
    At the risk of sounding rude, we have better things to do with our time than your research.
    Which it does, indeed. I resent the implication that I'm too stupid to look for the answer elsewhere before asking here. I am asking because I could not find it.

    You say you have better things to do - so instead of wasting time "doing my research," you waste your time insulting me. Bravo.

    -summit45

Similar Threads

  1. Problem with Regular Expression
    By jdluk87 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 2nd, 2012, 08:44 AM
  2. regular expression issue
    By flamant in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 22nd, 2012, 02:57 AM
  3. [SOLVED] Regular Expression Difficulties...
    By snowguy13 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: July 4th, 2012, 08:31 AM
  4. Regular expression handling
    By marquiseoflight in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 9th, 2012, 04:57 PM
  5. Regular Expression help
    By medoos in forum Java SE APIs
    Replies: 0
    Last Post: March 19th, 2011, 07:23 PM