Ruby regex for matching simpliest Ruby's regexes

泪湿孤枕 提交于 2019-12-06 16:56:05

As I commented above, you'll need to parse Ruby to differentiate division slashes and regex delimiters. But for the simplest, SIMPLEST case without worrying about this, how about:

regex_match = %r{/(?:[^/\\]|\\.)+/[mgixo]*}

That is "A forward slash, followed by one or more things that either aren't a forward slash or a backslash, or are a backslash followed by something else, finally followed by a slash, and possibly some regex flags."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!