What is going on here?

I noticed sweet_xml returns single quoted strings instead of double, and now I have this error where I can’t seem to do anything with these. I need to go reread how a ‘character map’ is different from a string, but…

why does this happen? (notice the 4 arguments

iex(7)> Regex.replace(regex, 'hello', "https://")
** (FunctionClauseError) no function clause matching in Regex.replace/4

    The following arguments were given to Regex.replace/4:

        # 1

        # 2

        # 3

        # 4

I am getting help on IRC but it seems it is this:

Single-quoted and double-quoted are not equivalent in Elixir. Single quoted are charlists (rarely used, unless you are interfacing with Erlang) and double-quoted are proper Elixir strings. Use double-quoted consistently and you should be good.


With sweet_xml you will need to provide the s modifier to your xpath calls. By default it will return a charlist. Instead of:

# Returns a charlist
xpath(my_doc, ~x"//a/text()")


# Return a binary (string)
# Note the "s" modifier
xpath(my_doc, ~x"//a/text()"s)

Sadly I already coded everything to deal with nil, so now i am writing another transformer :man_facepalming:t2: