# Validate for street

**URL:** <https://www.ruby-forum.com/t/validate-for-street/160772>\
**Category:** Rails\
**Created:** [February 19, 2009, 3:05pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772 "2009-02-19T15:05:21Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 3:05pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/1 "2009-02-19T15:05:21Z")

</div>

Hallo all,

can someone tell me what can be the regulare expression for this:  
“The Road”, “The Road 12”, “Road”, “On the Road 89”.

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/2 "2009-02-19T15:11:34Z")

</div>

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/](http://www.ruby-forum.com/).
> 
> >

If you want to match all strings, /Road/ will work

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)  
[http://www.linkedin.com/in/andrewtimberlake](http://www.linkedin.com/in/andrewtimberlake)

“I have never let my schooling interfere with my education” - Mark Twain

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 3:19pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/3 "2009-02-19T15:19:48Z")

</div>

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](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 4:34pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/4 "2009-02-19T16:34:42Z")

</div>

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](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)\*$/

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/5 "2009-02-19T17:50:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 9:00pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/6 "2009-02-19T21:00:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 9:06pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/7 "2009-02-19T21:06:09Z")

</div>

> > 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? (-:

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 19, 2009, 8:43pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/8 "2009-02-19T20:43:10Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![jobber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/848f3c/32.png) [@jobber](https://www.ruby-forum.com/u/jobber)\
**Post date:** [February 20, 2009, 8:46pm UTC](https://www.ruby-forum.com/t/validate-for-street/160772/9 "2009-02-20T20:46:01Z")

</div>

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
