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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:13:19+00:00 2026-05-26T04:13:19+00:00

I have a string [something]text1[/something] blah blah [something]text2[/something] I need to write a Perl

  • 0

I have a string

[something]text1[/something] blah blah [something]text2[/something]

I need to write a Perl script to read what is in the [something] tag, process it to “text-x”, and put it back with an [otherthing] tag. So the above string should be

[otherthing]text-1[/otherthing] blah blah [otherthing]text-2[/otherthing]

Processing “textx” to “text-x” is not one step process.

So this is solution that I have till now:

m/[something](?<text>.*)[/something]/

This will get me the string in between and I can process that to “text-x” but how do I put it back in the same place with [otherthing]text-x[/otherthing]?

  1. How do I use s/// in this case?
  2. How to do it for the whole string one by one ?
  • 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-26T04:13:19+00:00Added an answer on May 26, 2026 at 4:13 am

    You can use the /e switch on s/// to evaluate the right hand side before using the result as the substitution, and the /g flag to do this for every match.

    Here is a simple example:

    use 5.12.0;
    
    my $str = ">1<  >2<  >34<";
    
    $str =~ s/>(\d+)</">>".process("$1")."<<"/eg;
    
    say $str;
    
    sub process {
        return "x" x $_[0];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problems with pattern. I need to process some text for example: <div>{text1}</div><span>{text2}</span>
I have a function where I need to do something to a string. I
I have a string: type_name abc < text1 > text2 > > ab123 <
I have a string: Blah blah blah blah blah blah, and I need to
I have a string containing something like this Hello bla bla bla bla ok,
I have two classes class A { public string something { get; set; }
I have this line in the declarations section: Private filePath As String And something
So say I have a string like so of a path $path = '/path/to/../../up/something.txt';
So I have something like this: var xmlStatement:String = xmlObject.node[3].@thisValue; What mystery function do
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())

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.