|Well I find out the result myself using sed! Well with the help from using sed. After some search, I find out I can do the following:
1. Find bracket [ or ]
- I need to escape this in search string (\[ or \])
- To search for [abc] -> \[\([a-z]*\)\]
2. Find parentheses ( or )
- I do not escape this in search string
- To search for (123) -> (\([0-9]*\))
3. Use simple [a-z] or [0-9] instead of \S, \w, \d
Therefore I have:
echo [abc](123) | sed -e "s/\[\([a-z]*\)\](\([0-9]*\))/\2 \1/"
So in emacs, I do the following:
1. M-x regular-regexp
3. \2 \1
(Make sure there is a space between \2 and \1.)
modified 5-Aug-12 23:32pm.