Remove an apostrophe at the beginning or at the end of a word with regex

前端 未结 2 1434
隐瞒了意图╮
隐瞒了意图╮ 2021-01-25 08:14

I have a list of String that contains word. Some words have apostrophe at the beginning or/and at the end like this:

apple
\'orange
banana\'
joe\'s
         


        
2条回答
  •  半阙折子戏
    2021-01-25 09:13

    I understand my mistake, I forgot to make the assignment…

    myString = myString.replaceAll("(\B'\b)|(\b'\B)", "");
    

    Thank you and sorry for this dumb question.

提交回复
热议问题