I am expecting this to match only the first instance of <style
, because the second one, after the space has the pattern that I have put in the negative lookahead.
"<style type=\"text/html\">ciaoxocs <style />".scan /<style\s?(?!\/>)/
# => ["<style ", "<style"]
I want to an explanation for what is happening here, and possibly a better solution to match only the first instance without matching the closing tag with or without space:
<style /> or <style/>
In regex101.com, it works as expected with other langs: