- Erlang/OTP 17 [erts-6.0] [64-bit] [smp:4:4] [async-threads:10]
- Eshell V6.0 (abort with ^G)
- 1> A = <<"Chinaunix is here">>.
- <<"Chinaunix is here">>
- 2> l(re).
- {module,re}
- 3> re:
- compile/1 compile/2 grun/3 inspect/2 module_info/0
- module_info/1 replace/3 replace/4 run/2 run/3
- split/2 split/3 ucompile/2 urun/3
- 3> re:replace(A,<<here>>,<<there>>).
- ** exception error: bad argument
- 4> re:replace(A,<<"here">>,<<"there">>).
- [<<"Chinaunix is ">>,<<"there">>]
- 5> re:replace(A,<<"here">>,<<"there">>,[{return,binary}]).
- <<"Chinaunix is there">>
- 6>
复制代码- 6> f().
- ok
- 7> A = ["aaa","bbb","ccc"].
- ["aaa","bbb","ccc"]
- 8> [X,Y|_] = A.
- ["aaa","bbb","ccc"]
- 9> X.
- "aaa"
- 10> Y.
- "bbb"
复制代码- 11> f().
- ok
- 12> B={o,p,q,r,s,t}.
- {o,p,q,r,s,t}
- 13> {_,_,X,_} = B.
- ** exception error: no match of right hand side value {o,p,q,r,s,t}
- 14> {_,_,X,_,_,_} = B.
- {o,p,q,r,s,t}
- 15> X.
- q
- 16>
复制代码- 16> f().
- ok
- 17>
- 17> A = <<"Chinaunix is here">>.
- <<"Chinaunix is here">>
- 18> binary:re
- referenced_byte_size/1 replace/3 replace/4
- 18> binary:replace(A,<<"Chinaunix">>,<<"CU">>).
- <<"CU is here">>
- 19>
复制代码 |