Part of the fish philosophy is "it's not in fish if it's somewhere else"

    function regex_captures
        perl -E '$str=shift; $re=shift; say for $str =~ /$re/' $argv
    end

Then you can do something like this:

    $ regex_captures foobar 'f(.+)b(.+)' | while read match; set matches
$matches $match; end
    $ count $matches
    2
    $ for m in $matches; echo ">$m<"; end
    >oo<
    >ar<


On Thu, Oct 2, 2014 at 2:32 PM, Andrew Schulman <and...@utexas.edu> wrote:

> Hi. New fish user, and first post here.
>
> What's the recommended way to do regular expression testing and matching in
> fish?  The test function doesn't support regexes.  I could use expr, for
> example:
>
>   if expr $var : 'a(.)b(.)'
>   then
>     # do something with the match
>   end
>
> but that's awkward, because expr will only output the result of one match,
> it sends the result to stdout, and the exit status isn't necessarily 0 on
> success - it depends on the regex.
>
> What I'd like is to have is a function or operator whose exit status tells
> me whether the regex matched, and that returns an array of the matched
> results from ()... kind of like how (sorry) bash does it.
>
> Any suggestions?
>
> Thanks,
> Andrew.
>
>
>
> ------------------------------------------------------------------------------
> Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
> Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
> Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
> Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
>
> http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>



-- 
*Glenn Jackman*
Senior Software Developer

*Pythian - Love your data*
jack...@pythian.com
Tel: +1 613 565 8696 Ext. 1478
Mobile: +1 613 808 4984
www.pythian.com

-- 


--



------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to