CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions: Re: [gianni24] Regex mutiple match: Edit Log



BillKSmith
Veteran

Aug 30, 2017, 6:49 AM


Views: 5031
Re: [gianni24] Regex mutiple match

I am not certain what you need. My best guess is that you want to ignore leading and trailing whitespace and then find all partitionings of the remaining string which match a pattern. This is definitely not a job for a single regex!

If you can clarify your requirements, I will look into possible solutions.

UPDATE:
Perhaps this is what you want.

Code
C:\Users\Bill\forums\guru>type gianni24.pl 
use strict;
use warnings;
my $dict = " ABACUS ";

for my $i (0..length($dict)-1) {
$dict =~ /
^
\s*
(\w{$i})
([AOU])
(\w*)
\s*
$
/x;
next if !defined $3;
print "($1)($2)($3)\n";
}


C:\Users\Bill\forums\guru>perl gianni24.pl
()(A)(BACUS)
(AB)(A)(CUS)
(ABAC)(U)(S)

Good Luck,
Bill

(This post was edited by BillKSmith on Aug 30, 2017, 7:31 AM)


Edit Log:
Post edited by BillKSmith (Veteran) on Aug 30, 2017, 7:31 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives