I want to match the following string:
$this->request->data['utility_location_id']
Tried:
[[$]this[-][>]request[-][>]data[\[\'](\w{0,22})[\'\]]
Replace with: $this->request->getData\((\1)\)
Returns: $this->request->getData()utility_location_id']
What I want: $this->request->getData('utility_location_id')
However : The following one :
FInd :
[[$]this[-][>]request[-][>]data[\[\'](.*)[\'\]]
Replace : $this->request->getData\((\1)\)
Output : $this->request->getData('utility_location_id')
But it also matches the following string :
$this->request->data['utility_location_id']adasdadasd->datas sad sada ['utility_location_id']
which is a problem . How to fix it ? I know it is for (.*) .
[\[\']
is a character class, so it will match only one character. You should use [\[']+
instead or better just \['
. Same story for [\'\]]
.
Remember to use (?:X)
instead of [X]
for non-capturing groups.