我想知道是否有任何方法可以替换字符串中的子字符串,但替换它们之间的替换字符串。 I.E,匹配字符串"**"
的所有出现,并用"<strong>"
代替第一次出现,然后用"</strong>"
代替第一次出现(然后重复该模式)。交替替换子串
的投入将是这样的:"This is a sentence with **multiple** strong tags which will be **strong** upon output"
而返回的输出将是:"This is a sentence with <strong>multiple</strong> strong tags which will be <strong>strong</strong> upon output"
您可以在循环中将'IndexOf'与开始索引一起使用。 – CodesInChaos 2012-04-04 10:49:50
@CodeInChaos我没有真正使用IndexOf,经常会看看它,但你会有任何实现方法? – JakeJ 2012-04-04 10:51:18