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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:34:52+00:00 2026-06-09T01:34:52+00:00

I have a text file which contains strings with prefix A_B_. Example: A_B_Monday I

  • 0

I have a text file which contains strings with prefix A_B_.

Example: A_B_Monday

I would like to replace all occurences of A_B_* with X_Y_* except when * is C.

So all strings that are A_B_* but not A_B_C must be replaced by X_Y_*.

How should this be done in perl?

Edit:1
The * above is a string. So all A_B_* that are not A_B_Geneva should be replaced with X_Y_NewYork.
perl -pi.bak -e ‘s/^A_B_(!Geneva)/X_Y_/g;’ File.Txt does not seem to work. I am on Strawberry Perl.

Update:
This worked for me
perl -i.bak -pE “s/A_B_(?!Geneva)/USB_EP_/g” File.Txt

  • 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-09T01:34:54+00:00Added an answer on June 9, 2026 at 1:34 am

    Maybe:

    s/^A_B_(?!C)/X_Y_/;
    

    or:

    s/^A_B_(?!C)/X_Y_/i;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file which contains something like this: Hello, my name is
I have a text file which contains only lines with a message like: Hello
Problem I have a file which contains such text (nothing else) 2010-10-05 I would
I have the text file which contains 3 columns, first column having strings, second
I have a text file which contains data seperated by '|'. I need to
I have a simple text dictionary file, which contains words, separated by ';'.My problem
I have a text file which has a particular line something like sometext sometext
I have a text file which needs to be constantly updated (regular intervals). All
I have a text file (tab separated) which consist of 17 column. I would
I have a text file which contains columns of data that are either integer,

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.