Regular Expression problems

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
just_learning
Posts: 3
Joined: Tue Jan 06, 2004 5:35 pm

Regular Expression problems

Post by just_learning »

i cant do it.

here is the string pattern:

<meta NAME="Description" CONTENT="horse racing books thoroughbred trainer">

the string varies after "CONTENT="

i want to delete the entire meta description content entry, replacing it with nothing, across multiple pages, problem being the varying text after the content= part.
Thanks in advance.
User avatar
talleyrand
Posts: 624
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

So you want content equal to nothing or the whole line deleted?
Using POSIX reg exp syntax
Search for
(<meta NAME="Description" CONTENT=").*

If you wish to clear out the content but keep the line, replace with this
\1" />
Otherwise, if you want to remove the line, replace it with nothing.
I choose to fight with a sack of angry cats.
just_learning
Posts: 3
Joined: Tue Jan 06, 2004 5:35 pm

doesnt seem to work right

Post by just_learning »

I opened the files, went to |Search|Replace and then in the "find what" dialog i pasted this:
(<meta NAME="Description" CONTENT=").*
And I continued following instruction, replacing with nothing, etc, and in the "conditions" i checked the "Regular Expression" box, then clicked the "replace all" box. It fails. Can somebody try it out and please tell me how to delete the meta description line from 75 or so html files by using the replace function in textpad and regular expressions, please? Thank you. I just cant get it to work right.
User avatar
Bob Hansen
Posts: 1516
Joined: Sun Mar 02, 2003 8:15 pm
Location: Salem, NH
Contact:

Post by Bob Hansen »

All of the Regex explanations from talleyrand work perfectly.

Are you sure you have POSIX turned on? From the Main Menu, do this:
Configure, Preferences, Editor, Use POSIX check mark=YES, Apply, and OK.


OR without POSIX use his expression with the following modification:
\(<meta NAME="Description" CONTENT="\).*

Note: if doing a cut and paste from here to TextPad, be sure to strip out any trailing spaces after the pasting.
=============================
One other thought. This is your original example:
<meta NAME="Description" CONTENT="horse racing books
thoroughbred trainer">
Is there a real break in the line after "books", or does it just look that way because of the forum widths? There can be some issues on HTML pages because of "hidden" \n codes. Do the lines that are on the same line work OK with the Regex, and only the lines that "wrap" have a problem? It sounds like this may not be the issue and you are just struggling with the basic Search/Replace with Regex function. But I thought I should mention it.
Hope this was helpful.............good luck,
Bob
just_learning
Posts: 3
Joined: Tue Jan 06, 2004 5:35 pm

Thank you Bob Hansen and Talleyrand

Post by just_learning »

Well, I didn't follow the instructions careful enough. Yes, I did not have the Posix checked. I figured i was doing something wrong. Thank both of you........I did try very hard though, before "reasking".
Post Reply