Skip to content

Instantly share code, notes, and snippets.

@qfox
Created November 22, 2014 03:02
Show Gist options
  • Save qfox/2f520023226c1a3aeb81 to your computer and use it in GitHub Desktop.
Save qfox/2f520023226c1a3aeb81 to your computer and use it in GitHub Desktop.
sed-js2php
sed -r -e 's/module.exports.*$/<?php\nreturn function ($bh) {/' \
-e 's/bh\.match/\$bh->match/' \
-e 's/function\(ctx\)/function($ctx)/' \
-e 's/function\(ctx, json\)/function($ctx, $json)/' \
-e 's/ctx\./$ctx->/g' \
-e 's/(\s*)ctx$/\1$ctx/' \
-e 's/json\./$json->/g' \
-e 's/attrs\./$attrs->/g' \
-e 's/\.(\w+)/->\1/g' \
-e 's/(\w+) : /'\''\1'\'' => /g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment