regular expression to match the output - Ruby

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, MudGuard

Post Reply
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

regular expression to match the output - Ruby

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

If you provide precise details of the output you're referring to we may be able to help.
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

error format

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

thank you; getting close

Post by garison »

thank you; not taking it yet; but will continue to try to tweak it
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

should have noticed that before

Post by garison »

I might have noticed the ruby error matches java's in format.

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

file 1
line 4
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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).
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

Thank you

Post 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
ben_josephs
Posts: 2464
Joined: Sun Mar 02, 2003 9:22 pm

Post 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.
garison
Posts: 7
Joined: Mon Nov 01, 2010 6:55 pm

posix

Post by garison »

yes understood, did try that. btw -- hadn't noticed that before that will be generally handy I think
Post Reply