Dot-Star problem in Regex

0

I am trying to create a parser of robots.txt with Regex but I can not make the expression to be right. I ran several tests on Regex101 and still did not achieve an expected result.

My regular expression:

/user-agent: (bot|\*)\n*((disallow:\s*(?<disallow>.*)|allow:\s*(?<allow>.*)|sitemap:\s*(?<sitemap>.*))\n*)+/gi

My test suite:

User-agent: *

Disallow: /exemplo/
Allow: /dolor/
Disallow: /sit/
Allow: /amet/

Sitemap: http://www.loremipsum.com/sitemap.xml

In the image you can see the result that Regex101 returns and the one I wanted it to return.

    
asked by anonymous 05.07.2015 / 08:22

1 answer

0

After a few days thinking about how to do a parser , I was able to create something like Regex .

But the code is not 100% perfect and so I'm still testing it.

    
09.07.2015 / 03:56