Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3230634
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:57:00+00:00 2026-05-17T16:57:00+00:00

( Update: this question’s main focus is to test the nothing else part) Given

  • 0

(Update: this question’s main focus is to test the “nothing else” part)

Given a string s, which can contain anything, what is the most correct regexp in Ruby to check whether it is a single digit and nothing else? (a single digit and only a single digit).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:57:01+00:00Added an answer on May 17, 2026 at 4:57 pm

    Use /\A\d\z/

    irb(main):001:0> "asd\n7\n" =~ /\A\d\Z/
    => nil # works as false
    irb(main):002:0> "asd\n7\n" =~ /\A\d\z/
    => nil # works as false
    irb(main):083:0> "7\n"=~/\A\d\Z/
    => 0 # \Z fails, need \z
    irb(main):084:0> "7\n"=~/\A\d\z/
    => nil # works as false
    irb(main):005:0> "7" =~ /\A\d\Z/
    => 0 # works as true
    irb(main):006:0> "7" =~ /\A\d\z/
    => 0 # works as true
    

    http://www.zenspider.com/Languages/Ruby/QuickRef.html :

    \z            end of a string
    \Z            end of a string, or before newline at the end
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Update: this question is bunk. Move along, nothing to see here. You can set
Update: this question, including the title, was rephrased, see history for details I know
Duplicate of this question . update - This is not an exact duplicate. See
Update: Please read this question in the context of design principles, elegance, expression of
The same as this question but for java Update Based on the comments and
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
I think the question is pretty self explanatory. Anyone done this before? UPDATE :
Update: This question was inspired by my larger quest for mapping ontologically the whole
UPDATE : This question is not homework. And not waterproof apparantly... I wanted a
Update: this question is specifically about protecting (encipher / obfuscate) the content client side

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.