psmithphil
asked on
Add a semi-colon (;) at the end of each line of text with RegEx
I am trying to add a semi-colon (;) at the end of each line of text in a file with many lines. I want to use Regular Expressions to do it as I use UltraEdit editor (WindowsXP) which allows me to do a Search & Replace using Unix Regular Expressions. If I use "$" it looks like it affects the carriage return (it puts a block instead of a ";" on every other line and a ";" at the beginning & end of every other line).
If I use ".$", it picks the last character instead of putting it at the end of the line (I would expect this).
How can I put a semi-colon at the end of each line? Thank you for your help!
If I use ".$", it picks the last character instead of putting it at the end of the line (I would expect this).
How can I put a semi-colon at the end of each line? Thank you for your help!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, I got it to work. UltraEdit is a little different.
In the Find box I put (.+)$
In the Replace box I put \1;
That put a semi-colon at the end of each line. Sweet!
You two are the only ones who attempted to assist me and I appreciate it! I am splitting the points between you. Thank you!
In the Find box I put (.+)$
In the Replace box I put \1;
That put a semi-colon at the end of each line. Sweet!
You two are the only ones who attempted to assist me and I appreciate it! I am splitting the points between you. Thank you!
Regexes implementations vary a bit, so what might work for one language/platform may not work for another.
I must admit, I'm not sure why you are reluctant to run cygwin, if you are happy to install GNU Utilities for Windows.
I find cygwin is such a valuable tool on all my Windows boxes.
I must admit, I'm not sure why you are reluctant to run cygwin, if you are happy to install GNU Utilities for Windows.
I find cygwin is such a valuable tool on all my Windows boxes.
ASKER
I would prefer to use utilities like "sed", etc. The files I want to manipulate are in WindowsXP. I've tried using the GNU Utilities for Windows, but they are unreliable (I can't get the "$" to work consistently). And I don't want to use an emulator like Cgywin.
What I am therefore trying to use is the text editor UltraEdit. It allows me to use Unix Regular Expressions, but it has both search and replace boxes (like Microsoft Word), so I can't use things like "sed". What I'm trying to do is find how I can get to the end of the line to add the semi-colon. If I can't do it here, is there another way to do it?