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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:24:32+00:00 2026-06-12T16:24:32+00:00

the requirement I have is to check a string and based on particular set

  • 0

the requirement I have is to check a string and based on particular set of chars either insert or replace with prefix string

$prefix = "DV1";

Following are my source $input strings:

SS7.ABCWT2.RSND.LTE1.QR
IT4.ABCET2.VCE2.QR
Y88.ABCNT2.MIM.EDR2.QR
9C5.ABCS.MIM.EDR2.QR

the first chars before first . can be of any length
but after the first . the chars ABC remain constant followed by any one character – these four chars will always be there in my input string.
after these 4 chars, the i/p string may have two alphanumeric chars – T2 in this case.

what needs to be done is check if $input has “T2” (can be any two alphanum chars) and if it has then replace those 2 chars with D1 (any two chars from $prefix)

if $input does not have “T2”, then insert $prefix

  • 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-12T16:24:34+00:00Added an answer on June 12, 2026 at 4:24 pm

    This can be done quite straightforwardly with a single substitution. This program demonstrates

    The pattern looks for the sequence .ABC followed by any non-dot character. The \K protects that part of the pattern from being changed. Then there may be two optional non-dot characters, followed by a dot. The replacement string is D1 if the two optional characters were present, or the value of $prefix if not

    use strict;
    use warnings;
    
    my $prefix = 'DV1';
    
    while (<DATA>) {
      s/\.ABC[^.]\K([^.]{2})?(?=\.)/$1 ? 'D1' : $prefix/e;
      print;
    }
    
    __DATA__
    SS7.ABCWT2.RSND.LTE1.QR
    IT4.ABCET2.VCE2.QR
    Y88.ABCNT2.MIM.EDR2.QR
    9C5.ABCS.MIM.EDR2.QR
    

    output

    SS7.ABCWD1.RSND.LTE1.QR
    IT4.ABCED1.VCE2.QR
    Y88.ABCND1.MIM.EDR2.QR
    9C5.ABCSDV1.MIM.EDR2.QR
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have a requirement that I want to check the request headers and according
I have received a requirement to develop a feature to check if 2 email
I have a requirement where i need to configure a Spring based application to
In my application I have the requirement to check if the user has paid
I have a requirement where I need to check DB/@dbtype == 'oracle' (case insensitive).
I have a String variable abc . Now I would like to check whether
I have a requirement to 'check the integrity' of the content of files. The
I have this requirement to check for characters, numbers, and few special characters from
I have to check a number if it satisfies the following criteria: in binary,

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.