views:

271

answers:

4
+1  Q: 

regex in textpad

I'm trying to use textpad to search for a regular expression in several files.

it's a simple pattern but it doesn't work in textpad. It works fine in Visual Studio.

Anyone have any ideas?

searching for: hosted.mysite.com or host.mysite.com using (hosted|host).mysite.com

+2  A: 

try this:

 host\(ed\)?\.mysite\.com
akf
thanks for the quick reply. The host names are actually two different words entirely though...should've used a different example :/something like: somehost.mysite.com and bling.mysite.comin my original post I did have escape slashes before my dots but they got stripped.
Burrito
+1. Looking at http://www.textpad.com/support/tips/ it seems that many regex meta characters in TextPad need to be escaped in able to work properly. Odd. @OP, the above should work, and your own solution **should** work when you escape the logical OR as well: `\(hosted\|host\)\.mysite\.com` (untested!)
Bart Kiers
Burrito
It seems TextPad does not support the optional `?` quantifier.
Bart Kiers
@Burrito: if you have the `Use POSIX regular expression syntax preference` set in the Editor preference panel, you shouldn't escape the parens.
akf
...don't escape the pipe in the use POSIX RE syntax case either.
akf
+1  A: 

Not every text editor uses the same regex/conventions. A regex you may get to work in Visual Studio won't necessarily work in Eclipse, Netbeans, or some other IDE or text editor.

Geo
I'd vote +1, but this doesn't answer the question, does it? :) Anyway, good comment.
Seb
+4  A: 

Use something like this

\(hosted\|host\).mysite.com
Bob Breznak
+1: this works.
akf
note: if you have the Use POSIX regular expression syntax preference set in the Editor preference panel, you shouldn't escape the parens or the pipe.
akf
Thanks for the heads up on that.
Bob Breznak
A: 

In Textpad you need to escape some characters, such as parenthesis and pipes.

In your case, what you need is this:

\(hosted\|host\)\.mysite\.com

Note: you need to escape dots as well.

Seb
Bart suggested the same thing above and it's not flying....any other ideas?
Burrito
No idea, dude. I tested this before posting and it works in my box :(
Seb