I have a text file that I am searching for specific lines of code by using a PHP program.
In this example it is " $this->t()
".
I would like to find out what is in the brackets using RegEx.
Normally a ~->t\((.*?)\)~
would be good enough, but there are other options that don't fit at all.
$this->t('This is a text');
Should be This is a text
$this->t('This is %s a text' . $blabla);
Should be This is %s a text' . $blabla
$this->t('This %s is %s a text', $blabla, $not);
Should be 'This %s is %s a text'
$this->t('This, is %s a text ', $this);
Should be *This, is %s a text *
$this->t('This is %s a text ', $not);
Should be *This is %s a text *
$this->t('This is a text ', $not_this) . ' -> ' . $this->t('This is a ' . $big . ' Text', $not_this);
Should be *This is a text * and This is a ' . $big . ' Text
$this->t('You have %s sticker' . (count($x) == 1 ? '' : 's') . ' on your box', $x);
Should be You have %s sticker' . (count($x) == 1 ? '' : 's') . ' on your box
Basically, I'm looking for a solution for a pattern that captures all content starting with a ' or " and ending with the last ' or " OR up to the first comma outside the last ' or ".
->t\(([\"'](.*?)[\"'])\);
works only for functions with just one text encapsulated by ' oder "
->t\(([\"'](.*?)[\"'])(,.*)*\)
works much more efficient, but not really satisfactorily for
>t('Hello %s...', $firstname) . ' ' . $this->t('This is not me')
Unfortunately but I'm slowly running out of ideas.