What does this regex mean and why
Posted
by
Kalec
on Ask Ubuntu
See other posts from Ask Ubuntu
or by Kalec
Published on 2012-06-05T16:17:22Z
Indexed on
2012/06/05
16:48 UTC
Read the original article
Hit count: 939
$ sed "s/\(^[a-z,0-9]*\)\(.*\)\( [a-z,0-9]*$\)/\1\2 \1/g" desired_file_name
I apreciate it even if you only explain part of it or at lest structure it with words as in s\alphanumerical_at_start\something\alphanumerical_at_end\something_else\global
Could someone explain what that means, why and are all regEx so ... awful ?
I know that it replaces the first lowcase alphanumerical word with the last one. But could you explain bit by bit what's going on here ? what's with all the /\
and \(.*\)\
and everything else ?
I'm just lost.
EDIT: Here is what I do get: (^[a-z0-9]*)
starting with a trough z and 0 trough 9; and [a-z,0-9]*$
is the same but the last word (however [0-9,a-z]
= just first 2 characters / first character, or the entire word ?). Also: what does the *
or the \(.*\)\
even mean ?
© Ask Ubuntu or respective owner