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 8131675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:09:21+00:00 2026-06-06T09:09:21+00:00

My string is: (some text followed by) User ‘Mr.G@rr!s0n’ is the admin . I

  • 0

My string is: (some text followed by) User ‘Mr.G@rr!s0n’ is the admin.
I am using this regex pattern: /user\s'(.*)'\sis/i
However, I am getting the output as Mr.G!s0n

What exactly do I need to change in my regex pattern?


Here is the code snippet:

$text1 = "user 'Mr.G@rr!s0n' is the admin";

if($text1 =~ /user\s'(.*)'\sis/i)
{
    print "\n"; 
    print "Password: ".$1;
    print "\n";
}
  • 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-06-06T09:09:22+00:00Added an answer on June 6, 2026 at 9:09 am

    I am guessing your code (that you won’t show for some reason) is something like this:

    my $str = "(some text followed by) User 'Mr.G@rr!s0n' is the admin";
    if ($str =~ /user\s'(.*)'\sis/i) {
        print "$1\n";
    }
    

    The problem here is that @rr is interpolated because you are using a double quoted string. Since you are obviously not using:

    use strict;
    use warnings;
    

    ..this error is silent. If you had used them, you would have gotten:

    Possible unintended interpolation of @rr in string at
    Global symbol "@rr" requires explicit package name at
    

    To fix the problem, single quote your string using either '' or q():

    my $str = q#(some text followed by) User 'Mr.G@rr!s0n' is the admin#;
    

    As you notice, I used # as delimiter for q(), because both single quote and parentheses were already in the string.

    The other possibility is that you are using your match in some kind of evaluation, but that would be silly. So I am not going to make guesses there.

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

Sidebar

Related Questions

I have a string: [\n['-','some text what\rcontains\nnewlines'],\n\n trying to parse: Regex.Split(@[\n['-','some text what contains
I have a string like: hello #this# is #some text string# text text I
I have a string like this: |T1| This is some text for the first
I have the following text string: $ABCD(file=somefile.txt)$' />Some more text followed by a dollar
Say I have the following string: BlahBlah........1.000 Whatevah....2.000 Something......6.500 ...that is, some text, followed
How would I extract the dollar amount from the following string some text will
I'm trying to parse some Text with parsec: data Cmd = LoginCmd String |
I am giving a text view to tweet some string . I am applying
Given a text string containing a type name, is there some way to get
I'm looking to mine out some goodies from a multi-line string of text. I'm

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.