스택 교환 URL 일치


15

프롤로그

XSS 방지 브라우저 확장 프로그램을 설치 한 후 Stack Snippets는 모든 스택 교환 네트워크에서 갑자기 작동을 멈췄습니다. 더 이상 Stack Overflow 에서 배울 수 없었고 , 사용자 경험 에 대한 실습 데모를 볼 수 있었고, 최악의 경우 프로그래밍 퍼즐 및 코드 골프 에 대한 JavaScript 답변을 테스트 할 수 없었습니다 ! 필사적으로 치료법을 검색하고 설정에서 작은 입력 상자를 발견하여 단일 정규식을 배치 할 수있었습니다. 이 작은 상자에 모든 스택 교환 사이트를 설치할 수 없어서 도움을 요청했습니다. 이것이 그 질문입니다.

직무

귀하의 작업은 Stack Overflow Inc.에서 소유하지 않은 도메인과 일치하지 않고 모든 Stack Exchange 웹 사이트 URL과 일치하는 정규식을 작성하는 것입니다.

정규식은 모든 URL과 다음 부분이 일치해야합니다.

  • protocol: 이것은 http://또는 https://입니다.
  • domain:이 목록의 항목이됩니다.

    stackoverflow.com
    www.stackoverflow.com
    facebook.stackoverflow.com
    serverfault.com
    superuser.com
    meta.stackexchange.com
    webapps.stackexchange.com
    nothingtoinstall.com
    meta.webapps.stackexchange.com
    meta.nothingtoinstall.com
    gaming.stackexchange.com
    arqade.com
    thearqade.com
    meta.gaming.stackexchange.com
    meta.arqade.com
    meta.thearqade.com
    webmasters.stackexchange.com
    webmaster.stackexchange.com
    meta.webmasters.stackexchange.com
    meta.webmaster.stackexchange.com
    cooking.stackexchange.com
    seasonedadvice.com
    meta.cooking.stackexchange.com
    meta.seasonedadvice.com
    gamedev.stackexchange.com
    meta.gamedev.stackexchange.com
    photo.stackexchange.com
    photography.stackexchange.com
    photos.stackexchange.com
    meta.photo.stackexchange.com
    meta.photography.stackexchange.com
    meta.photos.stackexchange.com
    stats.stackexchange.com
    statistics.stackexchange.com
    crossvalidated.com
    meta.stats.stackexchange.com
    meta.statistics.stackexchange.com
    math.stackexchange.com
    maths.stackexchange.com
    mathematics.stackexchange.com
    meta.math.stackexchange.com
    diy.stackexchange.com
    meta.diy.stackexchange.com
    meta.superuser.com
    meta.serverfault.com
    gis.stackexchange.com
    meta.gis.stackexchange.com
    tex.stackexchange.com
    meta.tex.stackexchange.com
    askubuntu.com
    ubuntu.stackexchange.com
    meta.askubuntu.com
    meta.ubuntu.stackexchange.com
    money.stackexchange.com
    basicallymoney.com
    www.basicallymoney.com
    meta.money.stackexchange.com
    english.stackexchange.com
    elu.stackexchange.com
    meta.english.stackexchange.com
    stackapps.com
    ux.stackexchange.com
    ui.stackexchange.com
    meta.ux.stackexchange.com
    meta.ui.stackexchange.com
    unix.stackexchange.com
    linux.stackexchange.com
    meta.unix.stackexchange.com
    meta.linux.stackexchange.com
    wordpress.stackexchange.com
    meta.wordpress.stackexchange.com
    cstheory.stackexchange.com
    meta.cstheory.stackexchange.com
    apple.stackexchange.com
    askdifferent.com
    meta.apple.stackexchange.com
    rpg.stackexchange.com
    meta.rpg.stackexchange.com
    bicycles.stackexchange.com
    bicycle.stackexchange.com
    cycling.stackexchange.com
    bikes.stackexchange.com
    meta.bicycles.stackexchange.com
    meta.bicycle.stackexchange.com
    programmers.stackexchange.com
    programmer.stackexchange.com
    meta.programmers.stackexchange.com
    electronics.stackexchange.com
    chiphacker.com
    www.chiphacker.com
    meta.electronics.stackexchange.com
    android.stackexchange.com
    meta.android.stackexchange.com
    boardgames.stackexchange.com
    boardgame.stackexchange.com
    meta.boardgames.stackexchange.com
    physics.stackexchange.com
    meta.physics.stackexchange.com
    homebrew.stackexchange.com
    homebrewing.stackexchange.com
    brewadvice.com
    meta.homebrew.stackexchange.com
    meta.homebrewing.stackexchange.com
    security.stackexchange.com
    itsecurity.stackexchange.com
    meta.security.stackexchange.com
    meta.itsecurity.stackexchange.com
    writers.stackexchange.com
    writer.stackexchange.com
    writing.stackexchange.com
    meta.writers.stackexchange.com
    video.stackexchange.com
    avp.stackexchange.com
    meta.video.stackexchange.com
    meta.avp.stackexchange.com
    graphicdesign.stackexchange.com
    graphicsdesign.stackexchange.com
    graphicdesigns.stackexchange.com
    meta.graphicdesign.stackexchange.com
    dba.stackexchange.com
    meta.dba.stackexchange.com
    scifi.stackexchange.com
    sciencefiction.stackexchange.com
    fantasy.stackexchange.com
    meta.scifi.stackexchange.com
    codereview.stackexchange.com
    meta.codereview.stackexchange.com
    codegolf.stackexchange.com
    meta.codegolf.stackexchange.com
    quant.stackexchange.com
    meta.quant.stackexchange.com
    pm.stackexchange.com
    meta.pm.stackexchange.com
    skeptics.stackexchange.com
    skeptic.stackexchange.com
    skepticexchange.com
    meta.skeptics.stackexchange.com
    fitness.stackexchange.com
    meta.fitness.stackexchange.com
    drupal.stackexchange.com
    meta.drupal.stackexchange.com
    mechanics.stackexchange.com
    garage.stackexchange.com
    meta.mechanics.stackexchange.com
    meta.garage.stackexchange.com
    parenting.stackexchange.com
    meta.parenting.stackexchange.com
    sharepoint.stackexchange.com
    sharepointoverflow.com
    www.sharepointoverflow.com
    meta.sharepoint.stackexchange.com
    music.stackexchange.com
    guitars.stackexchange.com
    guitar.stackexchange.com
    meta.music.stackexchange.com
    sqa.stackexchange.com
    meta.sqa.stackexchange.com
    judaism.stackexchange.com
    mi.yodeya.com
    yodeya.com
    yodeya.stackexchange.com
    miyodeya.com
    meta.judaism.stackexchange.com
    german.stackexchange.com
    deutsch.stackexchange.com
    meta.german.stackexchange.com
    japanese.stackexchange.com
    meta.japanese.stackexchange.com
    philosophy.stackexchange.com
    meta.philosophy.stackexchange.com
    gardening.stackexchange.com
    landscaping.stackexchange.com
    meta.gardening.stackexchange.com
    travel.stackexchange.com
    meta.travel.stackexchange.com
    productivity.stackexchange.com
    meta.productivity.stackexchange.com
    crypto.stackexchange.com
    cryptography.stackexchange.com
    meta.crypto.stackexchange.com
    meta.cryptography.stackexchange.com
    dsp.stackexchange.com
    signals.stackexchange.com
    meta.dsp.stackexchange.com
    french.stackexchange.com
    meta.french.stackexchange.com
    christianity.stackexchange.com
    meta.christianity.stackexchange.com
    bitcoin.stackexchange.com
    meta.bitcoin.stackexchange.com
    linguistics.stackexchange.com
    linguist.stackexchange.com
    meta.linguistics.stackexchange.com
    hermeneutics.stackexchange.com
    meta.hermeneutics.stackexchange.com
    history.stackexchange.com
    meta.history.stackexchange.com
    bricks.stackexchange.com
    meta.bricks.stackexchange.com
    spanish.stackexchange.com
    espanol.stackexchange.com
    meta.spanish.stackexchange.com
    scicomp.stackexchange.com
    meta.scicomp.stackexchange.com
    movies.stackexchange.com
    meta.movies.stackexchange.com
    chinese.stackexchange.com
    meta.chinese.stackexchange.com
    biology.stackexchange.com
    meta.biology.stackexchange.com
    poker.stackexchange.com
    meta.poker.stackexchange.com
    mathematica.stackexchange.com
    meta.mathematica.stackexchange.com
    cogsci.stackexchange.com
    meta.cogsci.stackexchange.com
    outdoors.stackexchange.com
    meta.outdoors.stackexchange.com
    martialarts.stackexchange.com
    meta.martialarts.stackexchange.com
    sports.stackexchange.com
    meta.sports.stackexchange.com
    academia.stackexchange.com
    academics.stackexchange.com
    meta.academia.stackexchange.com
    cs.stackexchange.com
    computerscience.stackexchange.com
    meta.cs.stackexchange.com
    workplace.stackexchange.com
    meta.workplace.stackexchange.com
    windowsphone.stackexchange.com
    meta.windowsphone.stackexchange.com
    chemistry.stackexchange.com
    meta.chemistry.stackexchange.com
    chess.stackexchange.com
    meta.chess.stackexchange.com
    raspberrypi.stackexchange.com
    meta.raspberrypi.stackexchange.com
    russian.stackexchange.com
    meta.russian.stackexchange.com
    islam.stackexchange.com
    meta.islam.stackexchange.com
    salesforce.stackexchange.com
    meta.salesforce.stackexchange.com
    patents.stackexchange.com
    askpatents.com
    askpatents.stackexchange.com
    meta.patents.stackexchange.com
    meta.askpatents.com
    meta.askpatents.stackexchange.com
    genealogy.stackexchange.com
    meta.genealogy.stackexchange.com
    robotics.stackexchange.com
    meta.robotics.stackexchange.com
    expressionengine.stackexchange.com
    meta.expressionengine.stackexchange.com
    politics.stackexchange.com
    meta.politics.stackexchange.com
    anime.stackexchange.com
    meta.anime.stackexchange.com
    magento.stackexchange.com
    meta.magento.stackexchange.com
    ell.stackexchange.com
    meta.ell.stackexchange.com
    sustainability.stackexchange.com
    meta.sustainability.stackexchange.com
    tridion.stackexchange.com
    meta.tridion.stackexchange.com
    reverseengineering.stackexchange.com
    meta.reverseengineering.stackexchange.com
    networkengineering.stackexchange.com
    meta.networkengineering.stackexchange.com
    opendata.stackexchange.com
    meta.opendata.stackexchange.com
    freelancing.stackexchange.com
    meta.freelancing.stackexchange.com
    blender.stackexchange.com
    meta.blender.stackexchange.com
    mathoverflow.net
    mathoverflow.stackexchange.com
    mathoverflow.com
    meta.mathoverflow.net
    space.stackexchange.com
    thefinalfrontier.stackexchange.com
    meta.space.stackexchange.com
    sound.stackexchange.com
    socialsounddesign.com
    sounddesign.stackexchange.com
    meta.sound.stackexchange.com
    astronomy.stackexchange.com
    meta.astronomy.stackexchange.com
    tor.stackexchange.com
    meta.tor.stackexchange.com
    pets.stackexchange.com
    meta.pets.stackexchange.com
    ham.stackexchange.com
    meta.ham.stackexchange.com
    italian.stackexchange.com
    meta.italian.stackexchange.com
    pt.stackoverflow.com
    br.stackoverflow.com
    stackoverflow.com.br
    meta.pt.stackoverflow.com
    meta.br.stackoverflow.com
    aviation.stackexchange.com
    meta.aviation.stackexchange.com
    ebooks.stackexchange.com
    meta.ebooks.stackexchange.com
    alcohol.stackexchange.com
    beer.stackexchange.com
    dranks.stackexchange.com
    meta.alcohol.stackexchange.com
    meta.beer.stackexchange.com
    softwarerecs.stackexchange.com
    meta.softwarerecs.stackexchange.com
    arduino.stackexchange.com
    meta.arduino.stackexchange.com
    cs50.stackexchange.com
    meta.cs50.stackexchange.com
    expatriates.stackexchange.com
    expats.stackexchange.com
    meta.expatriates.stackexchange.com
    matheducators.stackexchange.com
    meta.matheducators.stackexchange.com
    meta.stackoverflow.com
    earthscience.stackexchange.com
    meta.earthscience.stackexchange.com
    joomla.stackexchange.com
    meta.joomla.stackexchange.com
    datascience.stackexchange.com
    meta.datascience.stackexchange.com
    puzzling.stackexchange.com
    meta.puzzling.stackexchange.com
    craftcms.stackexchange.com
    meta.craftcms.stackexchange.com
    buddhism.stackexchange.com
    meta.buddhism.stackexchange.com
    hinduism.stackexchange.com
    meta.hinduism.stackexchange.com
    communitybuilding.stackexchange.com
    moderator.stackexchange.com
    moderators.stackexchange.com
    meta.communitybuilding.stackexchange.com
    meta.moderators.stackexchange.com
    startups.stackexchange.com
    meta.startups.stackexchange.com
    worldbuilding.stackexchange.com
    meta.worldbuilding.stackexchange.com
    ja.stackoverflow.com
    jp.stackoverflow.com
    meta.ja.stackoverflow.com
    emacs.stackexchange.com
    meta.emacs.stackexchange.com
    hsm.stackexchange.com
    meta.hsm.stackexchange.com
    economics.stackexchange.com
    meta.economics.stackexchange.com
    lifehacks.stackexchange.com
    meta.lifehacks.stackexchange.com
    engineering.stackexchange.com
    meta.engineering.stackexchange.com
    coffee.stackexchange.com
    meta.coffee.stackexchange.com
    vi.stackexchange.com
    vim.stackexchange.com
    meta.vi.stackexchange.com
    musicfans.stackexchange.com
    meta.musicfans.stackexchange.com
    woodworking.stackexchange.com
    meta.woodworking.stackexchange.com
    civicrm.stackexchange.com
    meta.civicrm.stackexchange.com
    health.stackexchange.com
    meta.health.stackexchange.com
    ru.stackoverflow.com
    hashcode.ru
    stackoverflow.ru
    meta.ru.stackoverflow.com
    meta.hashcode.ru
    rus.stackexchange.com
    russ.hashcode.ru
    russ.stackexchange.com
    meta.rus.stackexchange.com
    mythology.stackexchange.com
    meta.mythology.stackexchange.com
    law.stackexchange.com
    meta.law.stackexchange.com
    opensource.stackexchange.com
    meta.opensource.stackexchange.com
    elementaryos.stackexchange.com
    meta.elementaryos.stackexchange.com
    portuguese.stackexchange.com
    meta.portuguese.stackexchange.com
    computergraphics.stackexchange.com
    meta.computergraphics.stackexchange.com
    hardwarerecs.stackexchange.com
    meta.hardwarerecs.stackexchange.com
    es.stackoverflow.com
    meta.es.stackoverflow.com
    3dprinting.stackexchange.com
    threedprinting.stackexchange.com
    meta.3dprinting.stackexchange.com
    ethereum.stackexchange.com
    meta.ethereum.stackexchange.com
    latin.stackexchange.com
    meta.latin.stackexchange.com
    languagelearning.stackexchange.com
    meta.languagelearning.stackexchange.com
    retrocomputing.stackexchange.com
    meta.retrocomputing.stackexchange.com
    crafts.stackexchange.com
    meta.crafts.stackexchange.com
    korean.stackexchange.com
    meta.korean.stackexchange.com
    monero.stackexchange.com
    meta.monero.stackexchange.com
    ai.stackexchange.com
    meta.ai.stackexchange.com
    esperanto.stackexchange.com
    meta.esperanto.stackexchange.com
    sitecore.stackexchange.com
    meta.sitecore.stackexchange.com
    
  • page: 이것은 빈 문자열 /이거나 /뒤에 오는 문자열입니다.

URL은 추가하여 만든 문자열입니다 protocol, domain그리고 page순서대로 서로에.

테스트 케이스

정규식이 다음과 일치해야합니다.

/codegolf//
http://retrocomputing.stackexchange.com
https://facebook.stackoverflow.com/questions/1234
http://meta.nothingtoinstall.com/thisisa404.php?file=command.com

정규식이 일치하지 않아야합니다.

http//codegolf.stackexchange.com/
https://meta.stackoverflow.com.fakesite.dodgy/cgi-bin/virus.cgi?vector=apt
file://www.stackoverflow.com/
http://ripoff.com/stackoverflow.com/q/1234/

정규식이 다음과 일치 할 수 있습니다.

http://panda.stackexchange.com/
https://www.meta.codegolf.stackexchange.com
http://alpha.beta.charlie.delta.chiphacker.com
https://stackexchange.com/sites/

이는 Stack Exchange Inc. 소유이며 XSS 공격에 취약하지 않기 때문입니다.

이것은 도전이므로 가장 짧은 정규 표현식이 승리합니다!


'일치 할 수있다'는 무슨 뜻입니까? 이것도 '매치해야한다'는 것이 아니어야합니까? 우리는 일반적으로 코드 골프 컨텍스트에서 바이트를 절약하기 위해 거의 항상 건너 뛰기 때문에 '보너스 목표'에 친절하게 취하지 않습니다.
orlp

@orlp 나는 이것을 출력이 예제처럼 보이는 한 프로그램이 후행 공백을 어느 정도 출력 할 수 있다는 ASCII 기술 문제와 같이 본다. 다시 말해, 프로그래머가 명시 적으로 허용하지 않는 것에 대해 걱정할 필요가없는 경우입니다. 그들이 실패하면 괜찮습니다. 일치하면 괜찮습니다.
DLosc

4
@orlp 나는 대부분의 구현 기술에서 바이트 를 절약 하기 때문에 추가했습니다 .
wizzwizz4

답변:


16

337 336 333 327 바이트

^https?://([^/]+\.)*(stackoverflow\.(com(\.br)?|ru)|mathoverflow\.(com|net)|hashcode\.ru|((the)?arqade|chiphacker|(mi)?yodeya|ask(ubuntu|different|patents)|(seasoned|brew)advice|s(erverfault|(tack|keptic)exchange|uperuser|tackapps|harepointoverflow|ocialsounddesign)|nothingtoinstall|crossvalidated|basicallymoney)\.com)(/.*)?$

멋진 정규식 기능을 사용하지 않으므로 모든 정규식 맛에서 작동해야합니다.


@TimmyD 내가 그것을 시도했을 때, 그것은 옵션 중 하나와 일치했습니다 ... regexr
wizzwizz4

@ wizzwizz4 스택 교환 및 시작 / 종료 마커를 잊었습니다.
orlp

@oflp 현재 일치하는 것이 없습니다 ... 정규식에서 시작 / 끝 마커가 작동하지 않습니까? regexr
wizzwizz4

@ wizzwizz4 단서가 없습니다. 나는 정규식을 사용하지 않습니다. 전체 텍스트가 아닌 한 번에 하나의 문자열을 입력하십시오.
orlp

1
당신은 결합하여 몇 바이트를 저장할 수 있습니다 seasonedadvice으로 brewadvice대신 서로 s단어.
Riley

5

359 348 바이트

https?:\/\/(([^/]+\.)*((stack(overflow|apps|exchange)|ask(ubuntu|different|patents)|(the)?arqade|serverfault|superuser|nothingtoinstall|(seasoned|brew)advice|crossvalidated|basicallymoney|chiphacker|skepticexchange|(sharepoint|math)overflow|(mi)?yodea|socialsounddesign)\.com)|(stackoverflow(\.com\.br|\.ru)|hashcode\.ru|mathoverflow\.net))(\/.*)?$

정규식에서 테스트하십시오.


3

2179 2092 1966 바이트

https?:\/\/((((www|facebook|jp|(meta\.?)?(es|ru|ja|pt|br)?)\.)?stackoverflow\.com)|(stackoverflow\.(ru|com\.br))|(((russ|meta)\.)?hashcode\.ru)|(crossvalidated|socialsounddesign|mathoverflow|(mi\.?)?yodeya|(www\.)?(sharepointoverflow|basicallymoney)|skepticexchange|brewadvice|(www\.)?chiphacker|ask(different|ubuntu)|stackapps|(meta\.)?(nothingtoinstall|arqade|thearqade|seasonedadvice|superuser|serverfault|ask(ubuntu|patents)))\.com|((meta\.)?mathoverflow\.net)|(((meta\.)?((3|three)dprinting|(ask)?patents|(community|world)building|(econo|acade)mics|(it)?security|(reverse|network)?engineering|a(cademia|i|lcohol|ndroid|nime|pple|rduino|stronomy|viation|vp)|b((e|lend)er|i(cycles?|kes|ology|tcoin)|oardgames?|ricks|uddhism)|c(h(emistry|ess|inese|ristianity)|ivicrm|o(de(review|golf)|ffee|gsci|mputer(science|graphics)|oking)|r(aftcms|afts|ypto(graphy)?)|s(50)?|stheory)|d(ba|eutsch|iy|ranks|rupal|sp)|(earth|data)science|e(books|l(ectronics|ementaryos|l|u)|macs|nglish|spanol|speranto|thereum|xp(at(s|riates)|ressionengine))|f(antasy|itness|re(elancing|nch))|g(a(medev|ming|rage|rdening)|erman|enealogy|is|raphics?designs?|uitars?)|h(am|ealth|ermeneutics|induism|istory|omebrew(ing)?|sm)|(hard|soft)warerecs|islam|italian|j(apanese|oomla|udaism)|korean|l(a((ndscap|nguagelearn)ing|tin|w)|i(fehacks|nguist(ics)?|nux|))|m(a(gento|rtialarts|th(educators|ematica|ematics|s|overflow)?)|eta|echanics|o(derators?|nero|ney|vies)|usic(fans)?|ythology)|o(pen(data|source)|utdoors)|(cycl|parent|retrocomput)ing|p(ets|h(ilosophy|oto(graphy|s)?|ysics)|m|o(ker|litics|rtuguese)|roductivity|rogrammers?|uzzling)|quant|r(aspberrypi|obotics|pg|us(s|sian)?)|s(alesforce|ci(comp|encefiction|fi)|harepoint|ignals|itecore|keptics?|ound(design)?|p(ace|anish|orts)|qa|tartups|tat(s|istics)|ustainability)|t(ex|hefinalfrontier|or|ravel|ridion)|u(buntu|i|nix|x)|vi(deo|m)?|w(eb(apps|masters?)|indowsphone|o(odworking|rdpress|rkplace)|rit(ers?|ing))|(yodeya)))\.stackexchange\.com))(\/|$)

나열된 도메인과 정확히 일치하며 다른 것은 없습니다. 나는 대부분의 압축을 손으로했다. 나는 이것에 많은 시간을 보냈다는 것이 조금 당황 스럽다.


.com압축 할 수 있습니까?
wizzwizz4

@ wizzwizz4 더 많이 압축 할 수 있다고 확신합니다. 나중에 다시 올 수도 있습니다.
Riley

1
모든 하위 도메인은 안전한 것으로 간주되므로 하위 도메인을 나열 할 필요가 없습니다.
curiousdannii

@curiousdannii 알고 있지만, 얼마나 작게 만들 수 있고 주어진 하위 도메인과 만 일치하는지 확인하고 싶었습니다.
라일리

2

142 140 334 바이트

#^https?:\/\/([^\/]*\.)?(hashcode\.ru|mathoverflow\.(com|net)|stackoverflow\.(ru|com(\.br)?)|((stack|skeptic)exchange|stackapps|ask(different|patents|ubuntu)|(brew|seasoned)advice|(the)?arqade|basicallymoney|chiphacker|crossvalidated|nothingtoinstall|serverfault|sharepointoverflow|socialsounddesign|superuser|(mi)?yodeya)\.com)(/|$)#
  • 지정된 두 번째 수준 도메인의 모든 항목, 경로 또는 경로 없음
  • #구분 기호로 사용 하므로 /이스케이프가 필요하지 않습니다 (2 바이트 절약).
  • 수동으로 압축
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.