# Regular expression hang ruby.exe

**URL:** <https://www.ruby-forum.com/t/regular-expression-hang-ruby-exe/228798>\
**Category:** RSpec\
**Created:** [May 8, 2013, 9:22am UTC](https://www.ruby-forum.com/t/regular-expression-hang-ruby-exe/228798 "2013-05-08T09:22:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maetthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@maetthew](https://www.ruby-forum.com/u/maetthew)\
**Post date:** [May 8, 2013, 9:22am UTC](https://www.ruby-forum.com/t/regular-expression-hang-ruby-exe/228798/1 "2013-05-08T09:22:53Z")

</div>

Hi,

I use an regular expression to verify that my string in time\_on\_site is  
correct. This works when the string match, but if it doesn’t the test  
get hanged. So I need to quit(ctrl+c) the script and also close ruby.exe  
\*32 in Task manager. Any ides how I can handle this?

time\_on\_site.should match(/^00:[0-5][0-9]$/)

Best regards  
Mattias

---

<div class="post-metadata">

**Author:** ![maetthew](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/dbc845/32.png) [@maetthew](https://www.ruby-forum.com/u/maetthew)\
**Post date:** [May 8, 2013, 9:42am UTC](https://www.ruby-forum.com/t/regular-expression-hang-ruby-exe/228798/2 "2013-05-08T09:42:42Z")

</div>

If I use below it returns correct output. Can I use something similar  
with Rspec so the test fails if its not true?

if time\_on\_site =~ /^00:[0-5][0-9]$/  
puts “# Successful match”  
else  
puts “# Match attempt failed”  
end
