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.
Hello G. (Guest)
on 2009-02-19 16: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".
Andrew T. (Guest)
on 2009-02-19 16:11
(Received via mailing list)
On Thu, Feb 19, 2009 at 4:05 PM, Hello G.
<removed_email_address@domain.invalid
> 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 T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
Rob B. (Guest)
on 2009-02-19 16:19
(Received via mailing list)
On Feb 19, 2009, at 9:05 AM, Hello G. 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 B.    http://agileconsultingllc.com
removed_email_address@domain.invalid
Hello G. (Guest)
on 2009-02-19 17:34
Rob B. wrote:
> On Feb 19, 2009, at 9:05 AM, Hello G. 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 B.    http://agileconsultingllc.com
> removed_email_address@domain.invalid

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)*$/
Frederick C. (Guest)
on 2009-02-19 18:50
(Received via mailing list)
On 19 Feb 2009, at 15:34, Hello G. 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
Phlip (Guest)
on 2009-02-19 21:43
(Received via mailing list)
Hello G. 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...
Hello G. (Guest)
on 2009-02-19 22:00
Phlip wrote:
> Hello G. 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?
Phlip (Guest)
on 2009-02-19 22: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? (-:
Hello G. (Guest)
on 2009-02-20 21:46
Phlip wrote:
> Hello G. 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.