Here is an simple example how to use regex in notepad++ with reusing selected match variables.

For example we have special code for simulating gcm notifications. We would like to see it in pretty style.
To achieve this we must to move all elements with minus to the new lines. How to do it? Here is the solution.

We have this string:
[java]adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -c com.example.android.debug -n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver –es “aaa” “123” –es “mmm” “bla bla bla” –es “sss” “321” –es “from” “111” –es “type” “yesterday” –es “collapse_key” “do_not_collapse”[/java]

By using bellow command in notepad++:

Searching text:

\-[a-z]{0,2}\s

Replace with:

\n($0)

We get the quite pretty result:
[java]adb shell am broadcast
-a com.google.android.c2dm.intent.RECEIVE
-c com.example.android.debug
-n com.example.android.google.debug/com.example.android.gcm.GcmBroadcastReceiver
–es “aaa” “123”
–es “mmm” “bla bla bla”
–es “sss” “321”
–es “from” “111”
–es “type” “yesterday”
–es “collapse_key” “do_not_collapse”[/java]

sorsare

By sorsare

Leave a Reply

Your email address will not be published. Required fields are marked *




Enter Captcha Here :