Page 1 of 1

regular expression to match the output - Ruby

Posted: Sat Nov 06, 2010 7:08 pm
by garison
Hi Group,

Anyone succeeded with regular expression to match the output for Ruby?

Don't get any search hits in that regard.

Thank You,

Gary

Posted: Sat Nov 06, 2010 8:53 pm
by ben_josephs
If you provide precise details of the output you're referring to we may be able to help.

error format

Posted: Sat Nov 06, 2010 9:37 pm
by garison
Thank you Ben,

error format is below, trying to extract the integer '39' on the first line, I think, is how te does it.


C:/Program Files/Ruby/work/lib/try1/domain1/recs.rb:39: syntax error
if args.size==1 then @width=args[0] end return @width

Posted: Sat Nov 06, 2010 10:57 pm
by ben_josephs
Select "Posix" regular expression syntax:
Configure | Preferences | Editor

[X] Use POSIX regular expression syntax
Then try
Regular expression to match output: ^(..[^:]+):([0-9]+):

Registers:
File: 1
Line: 2

thank you; getting close

Posted: Sat Nov 06, 2010 11:29 pm
by garison
thank you; not taking it yet; but will continue to try to tweak it

should have noticed that before

Posted: Sun Nov 07, 2010 12:51 am
by garison
I might have noticed the ruby error matches java's in format.

^\(\(\(.[^:]\)\|\([A-Za-z]:\)\)[^:]+\):\([0-9]+\):

file 1
line 4

Posted: Sun Nov 07, 2010 12:04 pm
by ben_josephs
This is the same as my suggestion, except that

1. it uses TextPad's default regular expression syntax instead of the far more readable "Posix" syntax (and it contains two pairs of redundant parentheses, increasing its unreadability), and

2. it takes unnecessary pains to ensure it doesn't match anything beginning with [^A-Z]: (anything that isn't a letter, followed by a colon).

Thank you

Posted: Sun Nov 07, 2010 3:41 pm
by garison
Thank you -- I wasn's getting the shorter, and as you say simpler, rgx to work (I'm sure due to my lack of fluency in rgx) so just copied in the textedit java string, which I definately can't read at this point.

When I have a moment, going to back to yours and play and see what I was doing wrong, need to regain and gain some rgx expertise.

thx much for the help

Gary

Posted: Sun Nov 07, 2010 5:48 pm
by ben_josephs
Make sure you select "Posix" regular expression syntax before you set the Regular expression to match output. TextPad interprets that regular expression in the regex style in use at the time it was set.

posix

Posted: Sun Nov 07, 2010 11:42 pm
by garison
yes understood, did try that. btw -- hadn't noticed that before that will be generally handy I think