Amoeba
Amoeba

Reputation: 75

Eclipse / Aptana regex search and replace

In Aptana (Eclipse), I want to replace in a lot of file PHP associative array by objects :

$requete["something"]

by

$row->something

I've tried this, SEARCH :

\$requete\[\"([\w.])+\"\]

with, REPLACE:

\$row->$1

but the regex engine only takes the last character of the search : g for something

Any ideas welcome ! Thanks

Upvotes: 5

Views: 1218

Answers (2)

jmohr
jmohr

Reputation: 4766

The reason the regex is only matching the last character of the group is the plus sign is outside the word match group. Also, the period is unneeded.

To fix the Regex, replace the period after the w with the plus sign

\$requete\[\"([\w]+)\"\]

Upvotes: 2

Narendra Yadala
Narendra Yadala

Reputation: 9664

Use \$requete\[\"(\w+?)\"\] for regex in the search portion. The issue with your current regex is that you are using the quantifier outside of the capturing group.

Upvotes: 1

Related Questions