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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:49:28+00:00 2026-05-30T08:49:28+00:00

Please do pardon me if my question sounds a bit awkward. I am looking

  • 0

Please do pardon me if my question sounds a bit awkward. I am looking for a regex which will replace line numbers in perl source file without affecting values assigned to scalars.

I think below will make my question a little bit clearer. Say I have a perl source which looks like this:

1. $foo = 2.4;
2. print $foo;

I would like a regular expression to replace those line numbers (1. 2. etc..) without affecting value assigned to scalars, and so in this case $foo.

Thanks

  • 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-30T08:49:29+00:00Added an answer on May 30, 2026 at 8:49 am

    Within a perl regex you can use the caret symbol ^ to represent the start of a line. $ represents the end of a line. These are known as anchors.

    So to find a number \d at the beginning of a line (only) you can search for

    /^\d+/
    

    If you wanted to remove those numbers you can “replace” them with nothing, as in

    s/^\d+//g
    

    You also want to include the dot after the number, so you might try
    ;

    /^\d+./
    

    But in regex a dot represents “any character” so you will need to escape the dot to have it interpreted literally

    /^\d+\./
    

    The caret symbol ^ also serves double-duty in character sets (it negates them), I only mention this as it is a common source of confusion when learning regex.

    /[^\d]/   # Match characters that are not digits
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please Pardon if the question sounds silly, but nevertheless its a question which I
Please pardon my ignorance. I'm looking for a point in the right direction. I
Please read the whole question. I'm not looking for an approach to managing multi-lingual
Perhaps this is a very basic question, please pardon me if it is ---
Please pardon me for a n00bish question. Please consider the following code: public class
Please pardon the newbie question, but I'm stumped. I'm a teacher converting a Rails
please pardon the absolutely newbie question but i'm very new to tableau. what I'd
Please pardon the naivety of this question. It's 2:00 AM. In doing some performance
Please note that this question is intended to be a bit more on the
I'm completely new to Simple Build Tool, so please pardon my beginner question. 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.