Find and replace before and after selection

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

Find and replace before and after selection

Postby joe4ska » Fri May 05, 2006 6:49 pm

I'm trying to create a find and replace macro to easily add html tags to the beginng and end of selected text.

I'm new to UE and normally use TextMate.

Lets say I select any word I want to bold in html.

I would like to have a macro add the <b> before and </b> after selected text.

In the find and replace I selected regular expressions and selected text.

How could I have ^ find before the selection and add <b> before the selection.

Likewise I would like $ to add a </b> at the end of the selection.

Ideas anyone?
User avatar
joe4ska
Newbie
 
Posts: 5
Joined: Thu May 04, 2006 11:00 pm

Re: Find and replace before and after selection

Postby mrainey56 » Fri May 05, 2006 7:00 pm

Read about Tag Lists in the help. The Tag List view can be opened with View - Views/Lists - Tag List.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Find and replace before and after selection

Postby joe4ska » Fri May 05, 2006 7:16 pm

Thanks for the help. I'm new to this application and its so much more powerful than anything else I've used so far. Also noticed that ^ in the regular expressions for beginning of line is actually % in UE.

Thanks again you answered my question. Also wish I checked that help file before asking :(
User avatar
joe4ska
Newbie
 
Posts: 5
Joined: Thu May 04, 2006 11:00 pm

Re: Find and replace before and after selection

Postby mrainey56 » Fri May 05, 2006 7:23 pm

There are three types of regular expressions available - UltraEdit, Unix, and Perl. There are some differences in the syntax that you have to be aware of.

Sometimes it's hard to know where to look in a big Help file if you don't get a bit of guidance first.
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Find and replace before and after selection

Postby joe4ska » Fri May 05, 2006 8:44 pm

Actually I'm having tons of problems.

All I want to do is create a simple macro that puts a html tag before and after a selection, but can't seem to get it to find the beginning of a selection and then the end of a selection for the final result.

<tag>selected text</tag>

Its far easier to hit a macro then to go into a tag menu for every little tag when you repeat it over the course of a large document.

How can I write a find and replace script that will do what I want?
User avatar
joe4ska
Newbie
 
Posts: 5
Joined: Thu May 04, 2006 11:00 pm

Re: Find and replace before and after selection

Postby mrainey56 » Fri May 05, 2006 10:22 pm

Try this for bold.

InsertMode
Cut
"<b>"
Paste
"</b>"
User avatar
mrainey56
Master
Master
 
Posts: 212
Joined: Tue Jul 27, 2004 11:00 pm
Location: Spartanburg, South Carolina

Re: Find and replace before and after selection

Postby joe4ska » Fri May 05, 2006 10:28 pm

It works, thank you so much for the advice. I don't know why it works, but now I can get crazy with my macros.
User avatar
joe4ska
Newbie
 
Posts: 5
Joined: Thu May 04, 2006 11:00 pm

Re: Find and replace before and after selection

Postby joe4ska » Fri May 05, 2006 10:32 pm

I see it was just a simple recoding of typing in the tag and cuting my html into and pasting it in between.

Wish I thought of that :D
User avatar
joe4ska
Newbie
 
Posts: 5
Joined: Thu May 04, 2006 11:00 pm

Re: Find and replace before and after selection

Postby Mofi » Sun May 07, 2006 7:43 am

For such simple tasks I use templates. For your example, the template would be <b>[$replace$]</b>

See also Usage of ^c and ^s in search and replace.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Find/Replace/Regular Expressions