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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:33:53+00:00 2026-05-18T11:33:53+00:00

I am trying to match patterns in perl and need some help. I need

  • 0

I am trying to match patterns in perl and need some help.

I need to delete from a string anything that matches [xxxx] i.e. opening bracket-things inside it-first closing bracket that occurs.

So I am trying to substitute with space the opening bracket, things inside, first closing bracket with the following code :

   if($_ =~ /[/)
  {
    print "In here!\n";
    $_ =~ s/[(.*?)]/ /ig;
  }

Similarly I need to match i.e. angular bracket-things inside it-first closing angular bracket.

I am doing that using the following code :

   if($_ =~ /</)
  {
    print "In here!\n";
    $_ =~ s/<(.*?)>/ /ig;
  }

This some how does not seem to work. My sample data is as below :

 'Joanne' <!--Her name does NOT contain "Kathleen"; see the section "Name"--> "'Jo'" 'Rowling', OBE [http://news bbc co uk/1/hi/uk/793844 stm Caine heads birthday honours list]  BBC News  17 June 2000  Retrieved 25 October 2000  , [http://content scholastic com/browse/contributor jsp?id=3578 JK Rowling Biography]  Scholastic com  Retrieved 20 October 2007  better known as 'J  K  Rowling' ,<ref name=telegraph>[http://www telegraph co uk/news/uknews/1531779/BBCs-secret-guide-to-avoid-tripping-over-your-tongue html Daily Telegraph, BBC's secret guide to avoid tripping over your tongue, 19 October 2006] is a British <!--do not change to "English" or "Scottish" until issue is resolved --> author best known as the creator of the [[Harry Potter]] fantasy series, the idea for which was conceived whilst on a train trip from Manchester to London in 1990  The Potter books have gained worldwide attention, won multiple awards, sold more than 400 million copies and been the basis for a popular series of films, in which Rowling had creative control serving as a producer in two of the seven installments  [http://www businesswire com/news/home/20100920005538/en/Warner-Bros -Pictures-Worldwide-Satellite-Trailer-Debut%C2%A0Harry Business Wire - Warner Bros  Pictures mentions J  K  Rowling as producer ] 

Any help would be appreciated. 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-18T11:33:54+00:00Added an answer on May 18, 2026 at 11:33 am

    $_ =~ /someregex/ will not modify $_

    Just a note, $_ =~ /someregex/ and /someregex/ do the same thing.

    Also, you don’t need to check for the existence of [ or < or the grouping parenthesis:

    s/\[.*?\]/ /g;

    s/<.*?>/ /g;

    will do the job you want.

    Edit: changed code to match the fact you’re modifying $_

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to match on a string that begins with ./media I have
I am trying to match words driven from a database in a string input
I'm trying to create a RegEx that matches the 3 patterns listed above. I
I'm trying to write a function that repeatedly matches regexp patterns against an input
I'm trying to delete some things from a block of text using regex. I
Possible Duplicate: preg_match() Unknown modifier '[' help I am trying to match this pattern
The pattern i am trying to match is some characters(letters+digits+hyphens (-) ) then 5
I'm trying to match a string against a pattern, but there's one thing I
I'm trying to match the '12345' from a url in this form: http://domain.com/folder/title_of_this_12345 So
I'm trying to match expressions that start with PRE and end with PRE. 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.