I need to write a regular expression to replace string @<Number|Text>@
to Text
in my iOS
application.
@<Number|Text>@
e.g.
@<12|abcd>@
will beabcd
@<1|I am a good boy>>>>>@
will beI am a good boy>>>>
@<a|abcd>@
no change, because the first part is not numeric@<0|god bless me@>>@
will begod bless me@>
@<01212|I love you!>@ Do you love me? @<0222| No, I love your sister>@
will beI love you! Do you love me? No, I love your sister
I am not familiar with regular expression, can someone help me?
What I have tried:
@<(\d{1,})\|([\S]+)>@
@<(\d{1,})\|([\S\s]+)>@
P.S. Any other solution is welcome. Actually what I want to do is replace @<ID|NAME>@
to @NAME
and make @NAME
as clickable(I use TTTAttributedLabel
), the url will be goto://ID