Searching in between text

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
mcai8rw2
Posts: 21
Joined: Mon Apr 04, 2005 10:00 am

Searching in between text

Post by mcai8rw2 »

Is there a way I can search and replace for certain tags that contain other text.

e.g. HTML FILES have a <title> GOOSE DOG MONKEY </TITLE> tag.

I need to search and replace this for ANOTHER title tag. Obviously one cant search/replace for <title> because that still leaves the other portion of the sentence.

thanks
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

I'm not sure exactly want you want to achieve.

You can search for entire elements including their beginning and ending tags (provided both tags are on the same line) with the regular expression

Code: Select all

<title>.*</title>
This will not work if a line may contain more than one element, as in

Code: Select all

one <title> GOOSE </title> element and another <title> MONKEY </title> element
because the match will extend from the first beginning tag to the last ending tag. If the contained text does not contain any '<' characters, you can prevent this with

Code: Select all

<title>[^<]*</title>
In WildEdit you can prevent such overlong matches more effectively with a non-greedy repeat:

Code: Select all

<title>.*?</title>
With WildEdit you can also search for text that extends over variable numbers of lines.
mcai8rw2
Posts: 21
Joined: Mon Apr 04, 2005 10:00 am

Perfect

Post by mcai8rw2 »

No you hit the nail on the head the first time!

<title>.*</title> was perfect it does just what I need.
Post Reply