Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在做这种匹配:
"125co.txt".match /^(?>\d{1,11})(?!af|a|f)((?:(?:c?o|co?).*)?.*)$/i
MatchData 对象是:
#<MatchData "125co.txt" 1:"co.txt">
作为该对象的第一项,我希望有匹配的数字(“125”)来执行某些任务。
它应该是:
#<MatchData "125co.txt" 1:"125" 2:"co.txt">
我能怎么做?
尝试使用额外的括号(?>\d{1,11}):
(?>\d{1,11})
/^((?>\d{1,11}))(?!af|a|f)((?:(?:c?o|co?).*)?.*)$/i