query-cca01b610d8493f84709929b9b59a31f
Conversion from format3 to format2 and format1 SELECT ?format1 ?format2 ?format3 ?num1 ?num2 ?num3 ?num4 { VALUES ?format3 { "09100220080003" "39800111000001" "52910200110001" "14840200270001" }
BIND (REPLACE(?format3, "(\d{3})(\d{3})(\d{4})(\d{4})", "$1-$2-$3-$4") AS ?format2)
BIND (REPLACE(?format3, "(\d{3})(\d{3})(\d{4})(\d{4})", "$1") AS ?num1) BIND (REPLACE(?format3, "(\d{3})(\d{3})(\d{4})(\d{4})", "$2") AS ?num2) BIND (REPLACE(?format3, "(\d{3})(\d{3})(\d{4})(\d{4})", "$3") AS ?num3) BIND (REPLACE(?format3, "(\d{3})(\d{3})(\d{4})(\d{4})", "$4") AS ?num4)
BIND (CONCAT( STR(xsd:integer(?num1)), "-", STR(xsd:integer(?num2)), "-", STR(xsd:integer(?num3)), "-", STR(xsd:integer(?num4))) AS ?format1) }
Use at
- https://query.wikidata.org/sparql
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
# Conversion from format3 to format2 and format1
SELECT ?format1 ?format2 ?format3 ?num1 ?num2 ?num3 ?num4
{
VALUES ?format3 { "09100220080003" "39800111000001" "52910200110001" "14840200270001" }
BIND (REPLACE(?format3, "(\\d{3})(\\d{3})(\\d{4})(\\d{4})", "$1-$2-$3-$4") AS ?format2)
BIND (REPLACE(?format3, "(\\d{3})(\\d{3})(\\d{4})(\\d{4})", "$1") AS ?num1)
BIND (REPLACE(?format3, "(\\d{3})(\\d{3})(\\d{4})(\\d{4})", "$2") AS ?num2)
BIND (REPLACE(?format3, "(\\d{3})(\\d{3})(\\d{4})(\\d{4})", "$3") AS ?num3)
BIND (REPLACE(?format3, "(\\d{3})(\\d{3})(\\d{4})(\\d{4})", "$4") AS ?num4)
BIND (CONCAT(
STR(xsd:integer(?num1)), "-",
STR(xsd:integer(?num2)), "-",
STR(xsd:integer(?num3)), "-",
STR(xsd:integer(?num4))) AS ?format1)
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v7("?format1"):::projected
v2("?format2"):::projected
v1("?format3"):::projected
v3("?num1"):::projected
v4("?num2"):::projected
v5("?num3"):::projected
v6("?num4"):::projected
bind0[/VALUES ?format3/]
bind0-->v1
bind00(["09100220080003"])
bind00 --> bind0
bind01(["39800111000001"])
bind01 --> bind0
bind02(["52910200110001"])
bind02 --> bind0
bind03(["14840200270001"])
bind03 --> bind0
bind1[/"replace(?format3,'(\d{3})(\d{3})(\d{4})(\d{4})','$1-$2-$3-$4')"/]
v1 --o bind1
bind1 --as--o v2
bind2[/"replace(?format3,'(\d{3})(\d{3})(\d{4})(\d{4})','$1')"/]
v1 --o bind2
bind2 --as--o v3
bind3[/"replace(?format3,'(\d{3})(\d{3})(\d{4})(\d{4})','$2')"/]
v1 --o bind3
bind3 --as--o v4
bind4[/"replace(?format3,'(\d{3})(\d{3})(\d{4})(\d{4})','$3')"/]
v1 --o bind4
bind4 --as--o v5
bind5[/"replace(?format3,'(\d{3})(\d{3})(\d{4})(\d{4})','$4')"/]
v1 --o bind5
bind5 --as--o v6
bind6[/"concat(str(http://www.w3.org/2001/XMLSchema#integer(?num1)),'-',str(http://www.w3.org/2001/XMLSchema#integer(?num2)),'-',str(http://www.w3.org/2001/XMLSchema#integer(?num3)),'-',str(http://www.w3.org/2001/XMLSchema#integer(?num4)))"/]
v3 --o bind6
v4 --o bind6
v5 --o bind6
v6 --o bind6
bind6 --as--o v7