1

I want every string inside $this->translate('') or $this->translate(""), I've come up with

grep -oe "\$this\->translate(\(['\"].*['\"]\))" -r dir/path

but this is bringing results like

$this->translate('Something?').'\');">'.$this->translate('Something else')

Each translate should be shown in separate lines. I tried using non-greedy/lazy but didn't work out.

Input samples

$this->translate('Something?').'\');">'.$this->translate('Something else')
<span><?= $this->translate('random text');?></span>

Expected output

Something
Something else
random text

Any thoughts?

  • 1
    so in your case grep -P -o '(?<=\$this->translate\(["'\''])[^)]*?(?=["'\'']\))' – don_crissti Oct 31 '16 at 20:13