great, simple is good here Lorenz. I tried $1 but was surprised to get
full strings bound to ?email on non-matches here as well. I had to
combine it with a filter of the same pattern to get the desired
results. so I read the replacement semantics here now that
backreference $0 is the input string
Or maybe even more simple
|BIND(REPLACE(STR(?url),".*/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/.*","$1")
AS ?email)|
>> BIND (REPLACE(STR(?s),"[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+","$0") AS ?email)
> replaces the matching email address by the email address itself, so it's
> the same as before.
>
> You need
> BIND (REPLACE(STR(?s),"[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+","$0") AS ?email)
replaces the matching email address by the email address itself, so it's
the same as before.
You need to replace everything else by the email address, replace is not
an "extract" function, you can try
BIND
very good Richard, thank you. I was working along these lines with the following
BIND (REPLACE(STR(?url),"[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+","$0") AS ?email)
where ?url contains the match but binds the entire string again to ?email
eg data:
url =
I think I'm familiar with functions on strings in SPARQL but as far as
I can see there is nothing similar to a grep like pattern matching and
extraction on strings for SPARQL. Or is there one?
Marco
--
---
Marco Neumann
KONA