Forum: Ruby on Rails validate for street

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8ecd2cd5666063da5ea09e8e39bb7bcc?d=identicon&s=25 Hello Guy (jobber)
on 2009-02-19 15:05
Hallo all,

can someone tell me what can be the regulare expression for this:
"The Road", "The Road 12", "Road", "On the Road 89".
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-02-19 15:11
(Received via mailing list)
On Thu, Feb 19, 2009 at 4:05 PM, Hello Guy
<rails-mailing-list@andreas-s.net
> wrote:

>
> Hallo all,
>
> can someone tell me what can be the regulare expression for this:
> "The Road", "The Road 12", "Road", "On the Road 89".
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
If you want to match all strings, /Road/ will work

Andrew Timberlake
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2009-02-19 15:19
(Received via mailing list)
On Feb 19, 2009, at 9:05 AM, Hello Guy wrote:
> Hallo all,
>
> can someone tell me what can be the regulare expression for this:
> "The Road", "The Road 12", "Road", "On the Road 89".


Your question doesn't make sense.  Do you mean a regular expression
that will match 'Road' in each of those?  If so, it's easy /Road/, but
I suspect you'll want to expand your question a bit.

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
8ecd2cd5666063da5ea09e8e39bb7bcc?d=identicon&s=25 Hello Guy (jobber)
on 2009-02-19 16:34
Rob Biedenharn wrote:
> On Feb 19, 2009, at 9:05 AM, Hello Guy wrote:
>> Hallo all,
>>
>> can someone tell me what can be the regulare expression for this:
>> "The Road", "The Road 12", "Road", "On the Road 89".
>
>
> Your question doesn't make sense.  Do you mean a regular expression
> that will match 'Road' in each of those?  If so, it's easy /Road/, but
> I suspect you'll want to expand your question a bit.
>
> -Rob
>
> Rob Biedenharn    http://agileconsultingllc.com
> Rob@AgileConsultingLLC.com

ok i ask so:
is this ok for like this  "The Road", "The Road 12", "Road", "On the
Road 89":
/^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-19 17:50
(Received via mailing list)
On 19 Feb 2009, at 15:34, Hello Guy wrote:
>
> ok i ask so:
> is this ok for like this  "The Road", "The Road 12", "Road", "On the
> Road 89":
> /^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/

Try it yourself in irb :-)

Fred
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-19 20:43
(Received via mailing list)
Hello Guy wrote:

> /^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/

Uh, what does (\s{1})* do?

In general, you cannot validate at this level of detail, because
addresses like
"The Batman, c/o Gotham City PD" will always fail. With terrible
consequences...
8ecd2cd5666063da5ea09e8e39bb7bcc?d=identicon&s=25 Hello Guy (jobber)
on 2009-02-19 21:00
Phlip wrote:
> Hello Guy wrote:
>
>> /^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/
>
> Uh, what does (\s{1})* do?
>
> In general, you cannot validate at this level of detail, because
> addresses like
> "The Batman, c/o Gotham City PD" will always fail. With terrible
> consequences...

hmm, what do you propose?
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-02-19 21:06
(Received via mailing list)
>> In general, you cannot validate at this level of detail, because
>> addresses like
>> "The Batman, c/o Gotham City PD" will always fail. With terrible
>> consequences...
>
> hmm, what do you propose?

Reward your customer, such as with free software, for providing correct
info? (-:
8ecd2cd5666063da5ea09e8e39bb7bcc?d=identicon&s=25 Hello Guy (jobber)
on 2009-02-20 20:46
Phlip wrote:
> Hello Guy wrote:
>
>> /^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/
>
> Uh, what does (\s{1})* do?
>
> In general, you cannot validate at this level of detail, because
> addresses like
> "The Batman, c/o Gotham City PD" will always fail. With terrible
> consequences...

This is correct for streetnames in germany, these are for example:
"Road", "This Road", "My Road 8"

I have write 8 tests and their validates in model. It works great.
Then I write
  def test_street_validate
   assert_match(/^[[:alpha:]]+(\s{1})*([[:alpha:]])*(\d)*$/, "Deine
Strasse")
 end

but i didnt write this validation in model and i do the test: there are
no
failures or errors.
i thought their must be one failure because his validation isnt in
model?

then when i write the street validation in model and do the test now,
there are 3 failures in 3 different tests.

whats that?

please help
This topic is locked and can not be replied to.