What flavor or regex does Ruby use?

I’m used to “Perl flavor” being used in the different languages I have experience with, so, knowing the basics, I haven’t looked too deeply into differences until I need to.

I was under the impression that the modifier “g” meant “greedy” not “global”.
https://meta.discourse.org/t/need-help-with-dialect-emitter/21358/8?u=mittineague

But it seems it means global
https://meta.discourse.org/t/need-help-with-dialect-emitter/21358/7?u=mittineague
Lines ~85 - 90
https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/markdown.js

What have I missed?

Looks like Perl.

This syntax is borrowed from Perl. Ruby supports the following modifiers:

/g means global in Perl as well.

The “g” stands for “global”, which tells Perl to replace all matches, and not just the first one.

There are different modifiers that are greedy. + and * both are I think.

Thanks.

It looks like my understand of “greedy” (match modifier vs. pattern modifier) was muddled.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.