0

I want to find the Wikidata resource corresponding to a specific website. This is my query

SELECT DISTINCT ?resource ?instanceOfLabel ?website
WHERE
{
    ?resource wdt:P856 ?website.
        FILTER (REGEX(str(?website), 'http(s)?://(\\w.)?smh.com.au/$')) .
  }           
} 

(link here) which doesn't return any result. This is not what I would expect since

SELECT DISTINCT ?resource ?instanceOfLabel ?website
WHERE
{
    ?resource wdt:P856 ?website.
        FILTER (REGEX(str(?website), 'http(s)?://www.smh.com.au/$')) .           
} 

(link here)

CptNemo
  • 6,455
  • 16
  • 58
  • 107
  • 1
    What do you expect is the meaning of `(\\w.)`? I mean what do you expect to match against it and how does it reflect the website scenario? – UninformedUser Aug 15 '16 at 05:43

1 Answers1

2

Pattern \w (written \\w to escape \) means one letter, but you expect three w letters as I understood.

To match three w you should use

'http(s)?://(w{3}.)?smh.com.au/$'

Though, what's the problem in using www?

'http(s)?://(www.)?smh.com.au/$'

If you want any three letters use

'http(s)?://(\\w{3}.)?smh.com.au/$'

Maybe you want just more than 0 of any letters?

'http(s)?://(\\w+.)?smh.com.au/$'

I guess, this answer will help you: How to represent a fix number of repeats in regular expression?

Community
  • 1
  • 1
Charlie
  • 826
  • 1
  • 11
  • 27