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

  • Home
  • SEARCH
  • 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 6808929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:01:00+00:00 2026-05-26T20:01:00+00:00

I would like to tell the difference between a number 1 and string ‘1’

  • 0

I would like to tell the difference between a number 1 and string '1'.

The reason that I want to do this is because I want to determine the number of capturing parentheses in a regular expression after a successful match. According the perlop doc, a list (1) is returned when there are no capturing groups in the pattern. So if I get a successful match and a list (1) then I cannot tell if the pattern has no parens or it has one paren and it matched a ‘1’. I can resolve that ambiguity if there is a difference between number 1 and string '1'.

  • 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-26T20:01:01+00:00Added an answer on May 26, 2026 at 8:01 pm

    For example, bitwise operators behave differently for strings and integers:

    ~1 = 18446744073709551614

    ~'1' = Î (‘1′ = 0x31, ~’1’ = ~0x31 = 0xce = ‘Î’)

    #!/usr/bin/perl
    
    ($b) = ('1' =~ /(1)/);
    print isstring($b) ? "string\n" : "int\n";
    ($b) = ('1' =~ /1/);
    print isstring($b) ? "string\n" : "int\n";
    
    sub isstring() {
        return ($_[0] & ~$_[0]);
    }
    

    isstring returns either 0 (as a result of numeric bitwise op) which is false, or “\0” (as a result of bitwise string ops, set perldoc perlop) which is true as it is a non-empty string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to tell the difference between a string that can
I'd like to tell the difference between valid and invalid date objects in JS,
I would like to tell the server to invalidate an ongoing session when the
Basically I would like to tell MSTest to execute a bit of code before
I have written JUnit tests for my class, and would like it to tell
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to test a string containing a path to a file for
So what I would like to do is scrape this site: http://boxerbiography.blogspot.com/ and create
I would like to ask in what situations could this even be possible? I've
We can use uname to tell the difference between iphone 3GS v.s. iphone 4

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.