the way it works, is it searches for an expression based on what you want.
\d represents any digit 0-9.
\w represents any word character.
you can use things like that for short instead of putting [a-zA-Z] or [0-9]
you need a starting and ending delimiter for the expression, / is common. You can use any character for it as long as it isn't alphanumeric or a backshash . If you use a delimiter that later appears in your expression, you must escape it using .
anything you enclose in () in your expression will be assigned to a numeric variable, starting at $1.
what this expression says is this:
/ (starting delimiter)
(\d+) (match any digit, + indicates one or more, so 0 works or 059 works...)
| (next we are looking for a |, we escape it because its a special character for regular expressions)
(\w+) (now we look for word characters, one or more times)
| (another pipe)
(\w+) (now we search for the last word characters)
/ (ending delimiter)
so following the expression:
/(\d+)|(\w+)|(\w+)/
---$1----$2-----$3-----
now that we have those parts in variables, we can setup our replace string.
simply put $1|$2|$3
to print our $1 then a pipe, then our $2 and our | escaped pipe, and the $3
for more, see
http://www.regexlib.com/ for a large library or regular expressions pre-written
http://www.regularexpressions.info/ for regex tutorials