Copy first 10 character of line to end of line

Find, replace, find in files, replace in files, regular expressions

Copy first 10 character of line to end of line

Postby RedShark » Fri Feb 04, 2005 5:43 am

I have a file were I need to copy the first ten character (a unique code) to the end of the line:

This is the original
QPH11002450A.help=Remarks

This should be
QPH11002450A.help=Remarks (QPH11002450A)

Each line has a different length, for example;
QPH11002450A.help=Remarks to the manager

Each line starts with 3 characters and is followed by 8 or 6 numbers and one character. Basicly I need the text before the "." copied to the end of the line.

How can I do this with reg. expressions / find and replace?
User avatar
RedShark
Newbie
 
Posts: 2
Joined: Fri Feb 04, 2005 12:00 am

Re: Copy first 10 character of line to end of line

Postby palou » Fri Feb 04, 2005 6:28 am

Hi RedShark,

Try this (without the quote""):

Find: "%^([a-zA-Z_0-9 ]+^).^(*^)$"
Replace: "^1.^2 (^1)"
Check: Regular Expression

This should make the job (expecting there is no other chars
than letters, numbers, underscore or space before the "." and
at least one of them).

Regards,
Alain
User avatar
palou
Basic User
Basic User
 
Posts: 46
Joined: Fri Dec 17, 2004 12:00 am
Location: Geneva / Switzerland

Re: Copy first 10 character of line to end of line

Postby RedShark » Fri Feb 04, 2005 7:23 am

Hi Palou,

Thanks, it worked great! And your example showed me a littble bit more of the use of regular expressions in my code! :D
User avatar
RedShark
Newbie
 
Posts: 2
Joined: Fri Feb 04, 2005 12:00 am


Return to Find/Replace/Regular Expressions