1

This question already has an answer here:

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?

marked as duplicate by don_crissti, HalosGhost, techraf, countermode, Anthon Oct 31 '16 at 21:45

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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