import re
import pywikibot
from pywikibot import pagegenerators as pg

site = pywikibot.Site('wikidata','wikidata')           #Geef aan naar welke site je wilt schrijven
repo = site.data_repository()                     #voor ophalen wikidata-items adhv Qxxxx
query='select ?item ?billboard where  {?item wdt:P4208 ?billboard}'

def wd_sparql_query(spq):
   generator=pg.WikidataSPARQLPageGenerator(spq,site=pywikibot.Site('wikidata','wikidata'))
   for wd in generator:
     try:
       wd.get(get_redirect=True)
       yield wd
     except:
       pass

print('Start')
for wd in wd_sparql_query(query):
   if ('P4208' in wd.claims):
     for claim in wd.claims['P4208']:
        billboardID=claim.getTarget()
        result=re.match(r"[0-9]{6}\/.{0,}",billboardID)
        if result!=None:
          print(f'{wd.title()}-{billboardID}-{result}')
          wd.removeClaims(claim,summary='id became obsolete')
print('Done')        
Start
WARNING: wikibase-lexeme datatype is not supported yet.
Q705715-369236/rupaul-<_sre.SRE_Match object; span=(0, 13), match='369236/rupaul'>
Q1095432-299372/clarence-gatemouth-brown-<_sre.SRE_Match object; span=(0, 31), match='299372/clarence-gatemouth-brown'>
Q125121-279868/aretha-franklin-<_sre.SRE_Match object; span=(0, 22), match='279868/aretha-franklin'>
Q4749315-278964/amy-meredith-<_sre.SRE_Match object; span=(0, 19), match='278964/amy-meredith'>
Q271385-280396/azealia-banks-<_sre.SRE_Match object; span=(0, 20), match='280396/azealia-banks'>
WARNING: wikibase-lexeme datatype is not supported yet.
Q661103-278715/alphabeat-<_sre.SRE_Match object; span=(0, 16), match='278715/alphabeat'>
Q7293289-361489/ranking-roger-<_sre.SRE_Match object; span=(0, 20), match='361489/ranking-roger'>
Q34389-431329/whitney-houston-<_sre.SRE_Match object; span=(0, 22), match='431329/whitney-houston'>
Q201392-301087/domenico-modugno-<_sre.SRE_Match object; span=(0, 23), match='301087/domenico-modugno'>
Q713270-277596/ulf-lundell-<_sre.SRE_Match object; span=(0, 18), match='277596/ulf-lundell'>
Q561320-304019/jacques-loussier-<_sre.SRE_Match object; span=(0, 23), match='304019/jacques-loussier'>
Q1058532-298890/chad-brock-<_sre.SRE_Match object; span=(0, 17), match='298890/chad-brock'>
Q41173-300744/demi-lovato-<_sre.SRE_Match object; span=(0, 18), match='300744/demi-lovato'>
Q337206-309818/marvin-hamlisch-<_sre.SRE_Match object; span=(0, 22), match='309818/marvin-hamlisch'>
Q290468-301951/evelyn-champagne-king-<_sre.SRE_Match object; span=(0, 28), match='301951/evelyn-champagne-king'>
Q25507-277927/accept-<_sre.SRE_Match object; span=(0, 13), match='277927/accept'>
WARNING: wikibase-lexeme datatype is not supported yet.
Q301378-310185/maxime-le-forestier-<_sre.SRE_Match object; span=(0, 26), match='310185/maxime-le-forestier'>
Q64074114-429931/tim-heintz-<_sre.SRE_Match object; span=(0, 17), match='429931/tim-heintz'>
Q963338-299983/dj-q-bert-<_sre.SRE_Match object; span=(0, 16), match='299983/dj-q-bert'>
WARNING: wikibase-lexeme datatype is not supported yet.
Q324726-276901/mac-miller-<_sre.SRE_Match object; span=(0, 17), match='276901/mac-miller'>
Q215310-279401/anna-bergendahl-<_sre.SRE_Match object; span=(0, 22), match='279401/anna-bergendahl'>
WARNING: wikibase-lexeme datatype is not supported yet.
Q18804-364745/rebecca-black-<_sre.SRE_Match object; span=(0, 20), match='364745/rebecca-black'>
Q316485-277605/ultravox-<_sre.SRE_Match object; span=(0, 15), match='277605/ultravox'>
Q72096-299088/chet-atkins-<_sre.SRE_Match object; span=(0, 18), match='299088/chet-atkins'>
Q2476571-303161/grim-reaper-<_sre.SRE_Match object; span=(0, 18), match='303161/grim-reaper'>
Q1335192-303291/g-rald-de-palmas-<_sre.SRE_Match object; span=(0, 23), match='303291/g-rald-de-palmas'>
Q354496-280524/stephen-stills-<_sre.SRE_Match object; span=(0, 21), match='280524/stephen-stills'>
Q613988-277247/queens-stone-age-<_sre.SRE_Match object; span=(0, 23), match='277247/queens-stone-age'>
Q278406-303508/high-fire-<_sre.SRE_Match object; span=(0, 16), match='303508/high-fire'>
Q365567-430270/toots-thielemans-<_sre.SRE_Match object; span=(0, 23), match='430270/toots-thielemans'>
Q8298-300445/david-guetta-<_sre.SRE_Match object; span=(0, 19), match='300445/david-guetta'>
Q1339711-304018/jacques-higelin-<_sre.SRE_Match object; span=(0, 22), match='304018/jacques-higelin'>
Q462380-277249/queensr-che-<_sre.SRE_Match object; span=(0, 18), match='277249/queensr-che'>
Q178832-305527/kasia-nosowska-<_sre.SRE_Match object; span=(0, 21), match='305527/kasia-nosowska'>
import re

rex=r"[0-9]{6}\/.{0,}"
str="123456/iets"

result=re.match(rex,str)
print(dir(result))