3

I'm trying to use TextPad to search for a regular expression in several files. I have a simple pattern but it doesn't work in TextPad. It works fine in Visual Studio.

Anyone have any ideas?

I'm searching for:

hosted.mysite.com or host.mysite.com

using the pattern:

(hosted|host)\.mysite\.com
random
  • 9,774
  • 10
  • 66
  • 83
Burrito
  • 33
  • 3

5 Answers5

5

Use something like this

\(hosted\|host\).mysite.com
BobBrez
  • 723
  • 7
  • 22
  • 1
    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 Oct 14 '09 at 20:41
  • Thanks for the heads up on that. – BobBrez Oct 14 '09 at 22:13
3

try this:

 host\(ed\)?\.mysite\.com
akf
  • 38,619
  • 8
  • 86
  • 96
  • 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.com in my original post I did have escape slashes before my dots but they got stripped. – Burrito Oct 14 '09 at 20:19
  • +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 Oct 14 '09 at 20:22
  • no dice. and yes that is very weird that you'd need to escape the meta chars...shouldn't it look for them literally then? Ohwell a topic for another time. But regardless, your solution still isn't flying. Any other ideas? I found this resource: http://docs.google.com/gview?a=v&q=cache%3AIN-HNpeNlG8J%3Awww-user.uni-bremen.de%2F~anatol%2Fdocs%2Fcorp_regex.pdf+Textpad+regex&hl=en&gl=ca&sig=AFQjCNGrbwIzN6j88cay-uq47TAojnyX1w&pli=1 – Burrito Oct 14 '09 at 20:28
  • It seems TextPad does not support the optional `?` quantifier. – Bart Kiers Oct 14 '09 at 20:36
  • @Burrito: if you have the `Use POSIX regular expression syntax preference` set in the Editor preference panel, you shouldn't escape the parens. – akf Oct 14 '09 at 20:40
  • ...don't escape the pipe in the use POSIX RE syntax case either. – akf Oct 14 '09 at 20:42
2

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
  • 93,257
  • 117
  • 344
  • 520
  • I'd vote +1, but this doesn't answer the question, does it? :) Anyway, good comment. – Seb Oct 14 '09 at 20:26
1

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
  • 24,920
  • 5
  • 67
  • 85
1

Textpad's POSIX regexes are good, but even better results could be achieved by installing the Win GNU util grep and adding a cmd /c "Prompt for parameters " , "Capture output" command: thus you could have full Find in files with even Perl regexes: grep -nhPr "CoolRegexToSearchWith" C:\MyDir\ToSearchRecursivly

Yordan Georgiev
  • 5,114
  • 1
  • 56
  • 53