permutation - Perl pattern matching with optional tokens -


I have such a string:

  $ word = "[A] ( Good [bad] word [for fun] ";   

Where:

  1. Everything inside [] is optional
  2. More The value of the inside (.. | ..) or mandatory value is

    Therefore, the possible results from the above string will be:

      A good for fun A bad word for word fun is a good word a bad   

    Did someone remove me from all possible outcomes Can help finding Rika (like the example given above) and helps find a way to store them in an array?

    Thanks!

    Use strict; continuous use (OPT = & gt; 0, or = & gt; 1, fixed = & Quot; My $ word = "[A] (good | bad) word [for fun]"; my @ talkence; # input parse my @v = grep {$ _} split / (\ [| \ ] | \ (| \ || \)) /, $ word; While ($ $ token = shift @ v) {if ($ token eck '' '] {push @ talkens, [op, change @ v]; shift @v; #]} alsf ($ token eq' (') { My @ list; make {push (@list, [fixed, change @ v]);} as long as (change @week ')'); # '|,)' push @ tokens, [or, \ @list] ; } And {push @ takkins, [vested, $ token]; }} #products my @phrases = (""); For my $ token (@ tokens) {my @additions; If ($ token-> [0] == opt) {Push @ pairs, $ _ $ Token- & gt; [1] @forfease; } Elsf ($ token-> [0] == Fixed) {$ _. = $ Token-> [1] @forfease; } Elsf ($ Token-> [0] == OR) {foreach my $ list (@ $ $ token-> [1]}) {push @ pairs, $ _ $ List-> [1] for @phrases; } @ Roos = (); } Push @ straps, @ added; } Print "$ _ \ n" map {s / ^ \ s + //; S / [] + / / g; $ _} @ For refresh;

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -