As I said in the comments, the problem here is that the wrong
question is being asked. But if you have to, and you can
exlude PO boxes (the string ends in a number?), and you limit
yourself to addresses in the USA (because you wouldn't believe
some of the things you see in the UK), then you might start by
detecting a leading number, then appending everything that isn't
separated from it by a space. It's hardly perfect, because
there'll always be people who write "99 A King St."
, rather
than "99a King St."
. (But then, in the first, is the name of
the street "King St."
or "A King St."
? Unless you know the
street yourself, you can't be sure.) The regular expression for
this would be "\\d+\\w*"
. Beyond that, you can try certain
heuristics with the results: if they are a single word, exactly
matching "St"
, "Street"
, "Ave"
, etc. (there are probably
about 20 different words you should check, with or without
trailing "."
in the case of abbreviations), then you probably
have just the street.
But before even starting, I would insist that you query the
assignment. It's well known, for example, that when inputting
addresses, about all you can do is "First line:"
, "Second
line:"
, etc. Even asking for a post code can be tricky.