bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: parenthesised regular expressions and non-greedy operator ? - non st


From: Greg Wooledge
Subject: Re: parenthesised regular expressions and non-greedy operator ? - non standard bash behaviour
Date: Fri, 1 Dec 2017 16:37:26 -0500
User-agent: NeoMutt/20170113 (1.7.2)

On Fri, Dec 01, 2017 at 06:40:35PM +0100, address@hidden wrote:
>   I'm sanitising urls from advertisement crap. As described below I'm getting 
> a wrong resolution of parenthesised expression defined with non-greedy 
> operator '?'.

> re='https?:\/\/toolbox.contentspread.net\/(.*?)=(.+?)&.*'
> 
> if [[ ${url} =~ ${re} ]]

Bash's =~ operator uses Extended Regular Expressions.  There is no
non-greedy operator (.*? or .+?) in an ERE.  It's a perl extension.

Also, you don't need to escape / but you *do* need to escape dots.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]