Find and replace regex in Intellij, but keep some of the matched regex?

Use the following regex replacement:

Find: myObject\[(.*?)\]
Replace: myObject.get($1)

If the index is an integer, you may replace (.*?) with (\d+).

The pair of unescaped parentheses creates a capturing group that we may reference from the replacement pattern using $ + Group ID. $1 will insert the index into the replacement result.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)