Help searching for two items with a wildcard inbetween...

General questions about using TextPad

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

Post Reply
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Help searching for two items with a wildcard inbetween...

Post by Soteriologist »

I'm searching for: ServerFilter=""
and: ""

With anything inbetween... so it'd look something like:

ServerFilter=""BLAHBLAHBLAHBLAH""

and i want to just be left with the BLAHBLAHBLAHBLAH
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Are the ServerFilter="" and "" parts both on the same line? Then:
Find what: ServerFilter=""(.*)""
Replace with: \1

[X] Regular expression
This assumes you are using Posix regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Post by Soteriologist »

Your find and replace DID work... but instead of it replacing with the text that was inbetween my 'find' items, it replaced it with literally "\1".

And to answer your first question, I BELIEVE all of the strings are on individual lines and not split.

"This assumes you are using Posix regular expression syntax:"

Where do I configure that at? Am I also supposed to be using TextPad? Because I'm not, I only have a license for WildEdit.

**UPDATE** I found the top option on WildEdit of the "Options Tab" under the "Syntax options" settings that says "Use POSIX extended, rather than ECMAScript syntax rules" so I've checkmarked that I'm trying it right now.
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Post by Soteriologist »

It doesn't seem to be working... I'm not sure what the exact result was. I'm still trying to figure out what happened.
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

This is a TextPad forum; a better place for your question would have been the WildEdit forum.

In WildEdit you use $1 instead of \1.

Don't worry about the Posix/ECMAScript setting.
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Post by Soteriologist »

I'm really sorry for posting in the wrong forum, but thank you for your help!

I'm also sorry for not bringing this up earlier, but what if I've got multiple occurences of the string to find and replace all on the same line of text?

Cause it still seems to not be working how I'd like it too, and I'm thinking that's why.

Thank you again ben_josephs. You're awesome for all the help you're giving me.
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
User avatar
MudGuard
Posts: 1295
Joined: Sun Mar 02, 2003 10:15 pm
Location: Munich, Germany
Contact:

Post by MudGuard »

ben_josephs wrote:This is a TextPad forum.
I disagree. This is a Regular Expressions forum.

But it might help if those who ask questions here mention which program they are using (and - if applicable - which regex machine [as in Wildedit: Posix or Ecmascript)
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

In WildEdit regular expressions:

A subexpression constructed with the * operator is greedy; it matches as much as possible. For example, the subexpression .* of the regular expression x.*y is greedy. If you use x.*y to search the text
x_stuff_y_x_more_stuff_y
the subexpression .* matches
_stuff_y_x_more_stuff_
and the whole expression matches the entire text.

On the other hand, a subexpression constructed with the operator *? is non-greedy; it matches as little as possible. In the above case x.*?y matches first
x_stuff_y
then
x_more_stuff_y

So the regular expression you need is
ServerFilter=""(.*?)""
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Post by Soteriologist »

I always wondered what they meant by greedy or non-greedy... Now it all makes sense. You're so awesome ben_josephs.

Thank you for your patience and help.

Your search expression works awesome, but the replace isn't replacing my "(.*?)"

It's putting in it's place either "$1" or "\1" when I try either one, and I've tried both with both "Use POSIX extended, rather than ECMAScript syntax and rules" checked and un-checked. So I dunno what the deal is now -_-.

Do I need to change any other options? like replace format, or my character endcoding? (it's currently set at the default of "windows-1252")
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Select Replacement format.
Soteriologist
Posts: 10
Joined: Tue Nov 14, 2006 2:29 am

Post by Soteriologist »

You're a beautiful man ben_josephs... beautiful.

If I were a lady, I'd want to have babies with you.

Needless to say, it worked wonderfully!!!
"Education is the progressive realization of our own ignorance" - Sir Albert Einstein
Post Reply