I have a problem with my query. I need to search through variables and if there is .
in a string I need to replace that specific character to _
.
I can replace empty spots and -
but I have a problem replacing a dot.
BIND(replace(?input,".","_") AS ?output) .
I have tried also use /.
, //.
, \.
, \\.
, basically anything but the result is the same.
Lexical error. Encountered: "<" <40>, after: "replace"
Thank you in advance.
Escape the dot with \\.
. You also might want to convert to string with STR
:
BIND(REPLACE(STR(?input),"\\.","_") AS ?output) .
You can also replace all of the characters with the same replace (here you don't need to escape the dot):
BIND(REPLACE(STR(?input),"[. -]","_") AS ?output) .
REPLACE
takes a regular expression as the second argument, that's why you need to escape the dot in the first one. In the second an escape is not needed as the dot is inside a character class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With