How to replace characters in string Erlang?

前端 未结 2 580
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 15:57

I have this piece of code that gets sessionid, make it a string, and then create a set with key as e.g. {{1401,873063,143916},<0.16443.0>} in redis. I\'m

2条回答
  •  天涯浪人
    2021-01-19 16:13

    re:replace(N,"{","a",[global,{return,list}]).
    

    Is this a good way of doing this? I read that regexp in Erlang is not a advised way of doing things.

    According to official documentation:

    2.5 Myth: Strings are slow

    Actually, string handling could be slow if done improperly. In Erlang, you'll have to think a little more about how the strings are used and choose an appropriate representation and use the re module instead of the obsolete regexp module if you are going to use regular expressions.

    So, either you use re for strings, or:

    leave { behind(using pattern matching) if, say, N is {{1401,873063,143916},<0.16443.0>}, then

    {{A,B,C},Pid} = N

    And then format A,B,C,Pid into string.

提交回复
热议问题