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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:52:07+00:00 2026-06-05T01:52:07+00:00

my input strings look like this: 1 warning: rg: W, MULT: file ‘filename_a.h’ was

  • 0

my input strings look like this:

1    warning: rg: W, MULT: file 'filename_a.h' was listed twice.
2    warning: rg: W, SCOP: scope redefined in '/proj/test/site_a/filename_b.c'.
3    warning: rg: W, ATTC: file /proj/test/site_b/filename_c.v is not resolved.
4    warning: rg: W, MULTH: property file filename_d.vu was listed outside.

They come in four different flavors as listed above. I read these from a log file line by line.

For the one with path specified (line 2,3) I can extract filename using $file=~s#.*/##; and seems to work fine. Is there a way not to use conditional statements for different type and extract the filename? I want to use just one clean regex and extract the filename. Perl’s File::basename will not work also in this case.

I am using Perl.

  • 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-05T01:52:10+00:00Added an answer on June 5, 2026 at 1:52 am

    You could do it in two steps:

    • extract path from each line
    • get basename from the path

    Example

    #!/usr/bin/perl -n
    use feature 'say';
    use File::Basename;
    
    #NOTE: assume that unquoted path has no spaces in it 
    say basename($1.$2) if /(?:file|redefined in)\s+(?:'([^']+)'|(\S+))/;
    

    Output

    filename_a.h
    filename_b.c
    filename_c.v
    filename_d.vu
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I query my mySql database table and retrieve text strings that look like this:
I have strings which look like string1 = ~01301~^~DATA1,DATA2 DATA3~^15.87^717^0.85^81.11^2.11^0.06^0 string2 = ~01341~^~DATA3,DATA2 DATA1
I have an input string that will look something like Monday 2:00 pm and
I have an input string I'm trying to parse. It might look like either
I have 2 arrays in PHP that look something like this: $rows = array(11,12,14,14,11,13,12,11);
I need to match input strings (URLs) against a large set (anywhere from 1k-250k)
I have an array of input strings that contains either email addresses or account
I give possibility to user to input strings with unique keys that represent one-line
The user should input two strings and the script will performe a text search:
I need a C# function that takes 2 strings as an input and return

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.