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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:07:04+00:00 2026-06-14T23:07:04+00:00

I have been working on a script to pull out useful commands from some

  • 0

I have been working on a script to pull out useful commands from some documentation and after searching online and playing with a few examples still can’t seem to get the regexp working correctly. The input file will be a word doc and I will need to extract some basic header info which I have working fine as well as all text between 2 sets of opening and closing tags which can span multiple lines and occur multiple times. Below is the code I have which pulls out the header details correctly but doesn’t seem to match and of the command headers through the doc.

open(DAT,'<input') or die "$!";
$file  = do{local $/; <DAT>};
close(DAT);
open (FH2, '>>', 'out.txt') or die "$!";
my @matches = $file =~ m/(\[$source\]|\[$target\]|\[admin\]|<IA%COMMAND>.*?       <\/IA%COMMAND>|<IA%UICOMMAND>.*?<\/IA%UICOMMAND>)/g;
print FH2 @matches;
close (DAT);
close (FH2);

The input file is a word doc which has a format similar to:

random overhead
[source]
<IA%COMMAND>stuff to print </IA%COMMAND>
stuff that should be ignored
[target]
<IA%UICOMMAND>other stuff to print</IA%UICOMMAND>
stuff to be ignored
[target]
<IA%COMMAND>print out this too
and this as well </IA%COMMAND>

Which should result in output:

[source]
<IA%COMMAND>stuff to print </IA%COMMAND>
[target]
<IA%UICOMMAND>other stuff to print</IA%UICOMMAND>
[target]
<IA%COMMAND>print out this too
and this as well </IA%COMMAND>

I broke it down to just searching for the open and close tags which matches fine but it doesn’t seem to be happy with .*? to do the nongreedy match for the content between the tags. Any advice would be appreciated.

  • 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-14T23:07:05+00:00Added an answer on June 14, 2026 at 11:07 pm
    s/(?:\A.*?(?=^\[[^[\]]*\](?:\n|\z)|\z)|(?<=[>\]]\n)(?!\[[^[\]]*\]*(?:\n|\z)|<[^>]*COMMAND>).*?(?=^\[[^[\]]*\](?:\n|\z)|^<[^>]*COMMAND>|\z))//gms;
    

    See this demo.

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

Sidebar

Related Questions

I have been working on this for some time. The script does work and
I have been working on trying to pull friends birthdays from the facebook API
I have been working on a script that pulls information from a certain website.
So I have been working on writing a script that takes in input from
I have been working on a script that pulls testimonials from a database, adds
I have recently been working on a Pastebin script (for fun) and I've come
I have been going mad trying to figure out why my scripts weren't working,
I have been trying to get a custom inventory script working in unrealscript. I
I have been working on this script: <script type=text/javascript src=/js/jquery.js></script> <script type=text/javascript> $(function(){ compentecy
I was turned on to nstrees from another question, and have been working through

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.