SilverAge Software

Search and Replace. Edit. Transform.

Use Cases

I need to change strings from osCommerce format to phpBB.

Question

I am working on a MOD to phpBB to integrate osCommerce and need all the language strings changed from the osCom format to the phpBB format.

I am wanting to write and expression to do the following but am having problems getting it to work: find code like this:

define('THIS_COULD_BE_ANYTHING', 'again anything');

and replace it with this

$lang['This_could_be_anything'] = 'again anything';

so that the first "T" in 'THIS_COULD_BE_ANYTHING' become capitalized.

Any pointers as to how to do this would be great - thanks. By the way - this is a great product, I use it at least once a week to update various files - searched through about 1000 files changing a couple of settings - fantastic ... well done.

Answer

It's very simple. We have to single out the two strings, the first one right after the opening bracket ending with the comma and the second one after the comma ending with the closing bracket.

Search expression

define\(\'([^\']+)\'\,\s+\'([^\']+)\'\)\;

where

Replace expression

$lang['\u\L\1\E'] = '\2';

where

  1. Type the search expression define\(\'([^\']+)\'\,\s+\'([^\']+)\'\)\; in the Find What field.
  2. Type the replacement expression in the Replace With field: $lang['\u\L\1\E'] = '\2';.
  3. Check the Regular Expressions box and uncheck the Force search only box.
  4. Click Replace.