I am getting completely different reults from string.scan and several regex testers…
I am just trying to grab the domain from the string, it is the last word.
The regex in question:
/([a-zA-Z0-9\-]*\.)*\w{1,4}$/
The string (1 single line, verified in Ruby’s runtime btw)
str = 'Show more results from software.informer.com'
Work fine, but in ruby….
irb(main):050:0> str.scan /([a-zA-Z0-9\-]*\.)*\w{1,4}$/
=> [["informer."]]
I would think that I would get a match on software.informer.com ,which is my goal.
It does not look as if you expect more than one result (especially as the regex is anchored). In that case there is no reason to use scan.
If you do need to use scan (in which case you obviously need to remove the anchor), you can use
(?:)to create non-capturing groups.