JasonDavis
JasonDavis

Reputation: 48933

RegEx to find and replace a pattern in SublimeText

I need to use a Regular Expression in SublimeText for a Find and Replace search.

My search string pattern looks like this:

chrome.i18n.getMessage("nimbusBtnLogin")

in which case I need to replace with:

"nimbusBtnLogin"

I have a GIST here https://gist.github.com/jasondavis/fda85e808a6c8184adad where I have listed the RegEx for a find and replace of HTML form selection option fields, links, and images however I was unable to modify and get working for this pattern above.

Can someone please share the correct RegEx?

Upvotes: 0

Views: 1637

Answers (1)

Wiktor Stribiżew
Wiktor Stribiżew

Reputation: 626690

You can use

\bchrome\.i18n\.getMessage\("([^"]*)"\)

Replace with $1. See the regex demo

Note:

  • \bchrome\.i18n\.getMessage\(" - matches literal string (matched as a whole word) chrome.i18n.getMessage(" (special characters are escaped since they must be treated as literals)
  • ([^"]*) - matches and captures into Group 1 any characters other than "
  • "\) - matches literal ")

Upvotes: 1

Related Questions