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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:01:49+00:00 2026-06-14T14:01:49+00:00

After considerable search on SO and Google, I resort to posting a new question.

  • 0

After considerable search on SO and Google, I resort to posting a new question. I am working with TextWrangler trying to compose a regular expression which will give me shortest matches of a multiple-line pattern.

Basically,

ہے\tVM

is the string I am looking for (an Arabic word separated by a tab character from its part of speech tag). What makes it difficult is that I would like to search for all single sentences containing that string. Here is what I have so far:

/(<Sentence id='\d+'>(?:[^<]|<(?!\/Sentence>))*ہے\tVM(?:[^<]|<(?!\/Sentence>))*<\/Sentence>)/

The files I am looking at are encoded in CML, so part of my question is whether any of you is aware of a CML parser for MAC?

Another obvious alternative is to write a Perl script — here again, I am thankful for any advice pointing to a simple solution.


My current script is:

use open ':encoding(utf8)';
use Encode;
binmode(STDOUT, ":utf8");
binmode(STDIN, ":utf8");

my $word = Encode::decode_utf8("ہے");

my @files = glob("*.posn");

foreach my $file (@files) {
    open FILE, "<$file" or die "Error opening file $file ($!)";
    my $file = do {local $/; <FILE>};
    close FILE or die $!;
    if ($file =~ /(<Sentence id='\d+'>(?:[^<]|<(?!\/Sentence>))*$word\tVM(?:[^<]|<(?!\/Sentence>))*<\/Sentence>)/g) {
            print STDOUT "$1\n\n\n\n";
            push(@matches, "$1\n\n");
            }
}

open(OUTPUT, ">matches.txt");
print OUTPUT "@matches";
close(OUTPUT);
  • 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-14T14:01:50+00:00Added an answer on June 14, 2026 at 2:01 pm

    You possibly may have more occurrences of the string in the input, so search for all of them…

    I believe your code should look like this >>

    use open ':encoding(utf8)';
    use Encode;
    
    binmode(STDOUT, ":utf8");
    binmode(STDIN,  ":utf8");
    
    my $word = Encode::decode_utf8("ہے");
    my @files = glob("*.posn");
    my @matches = ();
    
    foreach my $file (@files) {
      open FILE, "<$file" or die "Error opening file $file ($!)";
      my $file = do {local $/; <FILE>};
      close FILE or die $!;
      my @occurrences = $file =~ /<Sentence id='\d+'>(?:[^<]|<(?!\/Sentence>))*$word\tVM(?:[^<]|<(?!\/Sentence>))*<\/Sentence>/g;
      print STDOUT "$_\n\n\n\n" for (@occurrences);
      push (@matches, "$_\n\n") for (@occurrences);
    }
    
    open (OUTPUT, ">matches.txt");
    print OUTPUT  "@matches";
    close(OUTPUT);
    

    Learn more about regular expressions here.

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

Sidebar

Related Questions

After some considerable amount of time while trying to build the ffmpeg static library
After some time researching and trying different things I still cannot get my @ExceptionHandler
After a long search I'm still confused about it although I found some related
After considerable measurement, I have identified a hotspot in one of our windows services
I have considered posting this question on GameDev since my case relates to a
I'm trying to use the following code to create a new SalesInvoice based on
I'm just getting started with mobile development, and after considerable searching I'm still confused
Am working on web based Job search application using Lucene.User on my site can
I'm working on an interactive contact search page (contacts are returned via ajax as
Working for a considerable time on cracking some sales data, I came across an

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.