A
A
Anton2016-10-16 16:17:17
Ruby on Rails
Anton, 2016-10-16 16:17:17

Why does the regular expression work "in reverse"?

There is a regular expression: https://regex101.com/r/ZLTSoK/4
Which for some reason unknown to me does not work in Ruby:

re = /(.*?)(?:\(|\/)(?:.*?)\n/
line = re.match(tmp) if re.match(tmp).present?
puts line

tmpis the string to be parsed.
At the output, I get not "some text" or "even some text", but the exact opposite - what is in brackets, a slash, an ellipsis.
What could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question