Insert words at start and end of a line

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

Insert words at start and end of a line

Postby Enlightned » Sun Jul 09, 2006 2:21 pm

Hi

I'm new with UltraEdit, I was using other for 2 years now.
I need help with 2 things.

1) How can I remove ascii from a text?

2) How can I insert words at the beginning and end of each line?

This editor is great to use at work but I can't manage to do those things :(

tks in advance

Sorry my bad English
User avatar
Enlightned
Newbie
 
Posts: 2
Joined: Sat Jul 08, 2006 11:00 pm

Re: Insert words at start and end of a line

Postby Mofi » Mon Jul 10, 2006 5:13 am

1) Don't understand your question. How to delete characters can be done as in every other editor.

2) With a regular expression described several times in the forum. Here is once again the solution for UltraEdit style:

Find What: %^(*^)$
Replace With: your words^1your words

The same regex replace in Unix or Perl style:

Find What: ^(.*)$
Replace With: your words\1your words

See help of UltraEdit about the Find command and Regular Expressions for an explanation.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4051
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Insert words at start and end of a line

Postby Enlightned » Tue Jul 11, 2006 4:57 pm

That's not what I mean.

I'll give you an example.

Imagine an info from some scene team. The have all those ascii.
What I want is remove all those ascii and keep just the text.

The other question is simple. I just want to know how insert text at the beginning and end of each line.

Ex:

line 1
line 2
line 3
...

What I want to do is insert "example" like this:

example line 1
example line 2
example line 3
...

But with thousands of lines.

Thanks for your reply
User avatar
Enlightned
Newbie
 
Posts: 2
Joined: Sat Jul 08, 2006 11:00 pm

Re: Insert words at start and end of a line

Postby Mofi » Wed Jul 12, 2006 5:33 am

Enlightned wrote:Imagine an info from some scene team. The have all those ascii. What I want is remove all those ascii and keep just the text.


ASCII is the name of a standard and not a set of characters. To remove all unwanted characters use following regular expression.

Find What: [...]
Replace With: nothing

The ... is just a place holder for all the characters you want to delete. Copy and paste them into it. You can also use the invert character set and delete all characters except ... This can be done in UltraEdit style with

Find What: [~0-9A-Z ^t^p_,.;^*:...]
Replace With: nothing

Again ... is just a place holder for further standard characters. Use View - ASCII Table to get an overview of the characters and read carefully the whole help about the Find Command and the Regular Expressions.

Enlightned wrote:The other question is simple. I just want to know how insert text at the beginning and end of each line.


And this question I have answered already.

You should execute the replace commands with click on button Replace All and not step by step.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4051
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Insert words at start and end of a line

Postby Maryue » Wed Jul 12, 2006 7:01 pm

To add the word "Example" at the start of each line:
Replace ^p with ^pExample

To put it at the end of the line:
Replace ^p with Example^p

^p designates a hard return.
User avatar
Maryue
Newbie
 
Posts: 3
Joined: Tue Jul 11, 2006 11:00 pm

Re: Insert words at start and end of a line

Postby cwq2008119 » Tue Jul 25, 2006 7:35 am

Mofi is right.
for example: I want to insert "start" at the beginning and "end" at the end of every line.

InsertMode
ColumnModeOff
HexOff
UnixReOff
Find RegExp "%^(*^)$"
Replace All "start ^1 end"

as following:
line1: a
line2: b
line3: c
line4: d

the result is:
line1:start a end
line2:start b end
line3:start c end
line4: d

But I don't understand why the last line is not processed.
User avatar
cwq2008119
Newbie
 
Posts: 6
Joined: Wed Jul 19, 2006 11:00 pm

Re: Insert words at start and end of a line

Postby mrainey56 » Tue Jul 25, 2006 9:49 am

Make sure there's a return at the end of the last line.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina


Return to Find/Replace/Regular Expressions