Regex for removing a specific BBCode from a string

前端 未结 3 1856
陌清茗
陌清茗 2021-01-20 11:27

I\'m trying to write a simple method for removing specific BBCodes from an input string.

For example, where I have an input of:

string input = \"[b]H         


        
3条回答
  •  星月不相逢
    2021-01-20 12:00

    If you sure that both starting and trailing special symbol must occur and you don't want them to be in a result, you can use positive look back ((?<=(your symbols here))) and positive look ahead ((?=(your symbols here))) for specified characters.

    Complete answer will look like this:

    (?<=(\[{0}\])).*(?=(\[\/{1}\]))
    

提交回复
热议问题