Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

How to check for not beginning of line

Last post 07-27-2009, 11:18 AM by ddrudik. 2 replies.
Sort Posts: Previous Next
  •  06-16-2009, 1:38 PM 53980

    How to check for not beginning of line

    Hello,

    I am using a java platform.

    Trying to capture everything past the last whitespace like this:  ([^\s]+$)

     So Input:  "My name is Marven" --> "Marven"   (pretty much selecting last word)

    I need to check if there is no whitespace, do not select the word.  I want to make sure nothing is selected if there is only one word and no whitespace.  Maybe check for beginning of line with "^"?

     I..e right now: "Marven" --> "Marven"

    I need: "Marven" --> n/a

     

    Thanks in advance!

  •  07-27-2009, 10:36 AM 55424 in reply to 53980

    Re: How to check for not beginning of line

    Did you find a solution yet?

    This may work: .*\s(\w+)\s*$

    It selects the last work, but only if there is a space before it, and ignores trailing whitespace to the end of the line.

    It will match a single word on a line if there is white space before it, so I'm not sure if that quite meets your need.

     

    Batkins61

  •  07-27-2009, 11:18 AM 55425 in reply to 53980

    Re: How to check for not beginning of line

    Consider (?<=\s)\S+$


View as RSS news feed in XML