我有一個方法帶(),這裏是其使用的範圍內:查找「相反」或關閉字符
public String strip(String data, String tag)
{
...
}
@param data a string where all open symbols such as [({ have a matching close somewhere after them.
@param tag an opening symbol(such as "["
@return a substring of the contents between the first given opening and the last corresponding closing character- with both characters removed.
example:
strip("caca blah blah [ hb {} ((stuff){okay} vv]","[")
should return "hb {}((stuff)(okay) vv"
我的問題 - 我心中有一個解決方案,但我試圖找到一種方法找到所給出的那個「相反」或閉合字符,而不用手編碼所有可能的組合。字符編碼是否存在某種技巧或模式,或者某種程度上可能是實用程序方法?
? 'a [b] [c] d'會給'b] [c'。 – Henry 2014-09-06 04:57:02
我並不真正關心這個方法本身 - 它的任意性,但是謝謝你指出 – 2014-09-06 05:44:23