Skip to content

Instantly share code, notes, and snippets.

@nelsonr
Created July 5, 2012 09:52
Show Gist options
  • Save nelsonr/3052693 to your computer and use it in GitHub Desktop.
Save nelsonr/3052693 to your computer and use it in GitHub Desktop.

Revisions

  1. nelsonr revised this gist Jul 9, 2012. No changes.
  2. nelsonr revised this gist Jul 9, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Super Komodo PHP Regex
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    Note! - This gist uses Komodo specific regex shortcuts
    Regex for PHP associative array keys that lack quotes

    ------------------------------------------------------

    Find with: \$([a-z0-9_]*)\[(?!('|"))([a-z0-9_]*)(?!('|"))\]
    Replace with: $\1['\3']

    \1 and \3 relate to groups in the expression that are whatever what's inside parenthesis.
    \1 and \3 relate to groups in the expression that are whatever what's inside parentheses.

    The first and third group ([a-z0-9_]*) are equal and each one
    matches the variable name and the key name respectively
  3. nelsonr revised this gist Jul 6, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions Super Komodo PHP Regex
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,11 @@ Note! - This gist uses Komodo specific regex shortcuts
    Find with: \$([a-z0-9_]*)\[(?!('|"))([a-z0-9_]*)(?!('|"))\]
    Replace with: $\1['\3']

    \1 and \3 relate to groups in the expression that are whatever what's inside parenthesis.

    The first and third group ([a-z0-9_]*) are equal and each one
    matches the variable name and the key name respectively

    ------------------------------------------------------

    Matches the following:
  4. nelsonr revised this gist Jul 6, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Super Komodo PHP Regex
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ Note! - This gist uses Komodo specific regex shortcuts

    ------------------------------------------------------

    Find with: \$(.*)\[(?!('|"))(.*)(?!('|"))\]
    Find with: \$([a-z0-9_]*)\[(?!('|"))([a-z0-9_]*)(?!('|"))\]
    Replace with: $\1['\3']

    ------------------------------------------------------
  5. nelsonr created this gist Jul 5, 2012.
    22 changes: 22 additions & 0 deletions Super Komodo PHP Regex
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    Note! - This gist uses Komodo specific regex shortcuts

    ------------------------------------------------------

    Find with: \$(.*)\[(?!('|"))(.*)(?!('|"))\]
    Replace with: $\1['\3']

    ------------------------------------------------------

    Matches the following:

    $your_var_name[your_assoc_key]

    Which will turn into:

    $your_var_name['your_assoc_key']

    ------------------------------------------------------

    Won't match:

    $your_var_name["your_assoc_key"] or $your_var_name['your_assoc_key']