2020年10月8日 星期四

Java 正規表示式 (?s)

最近在作Tableau API response XML String parse.

找到這個Sample 可以把指定的Tag 過濾掉.

xml = xml.replaceFirst("(?s)]*>.*?</tagname[^>","");

不了解(?s) 的意思. 請Google 大神幫忙

  • (?i) makes the regex case insensitive.

  • (?s) for "single line mode" makes the dot match all characters, including line breaks.

  • (?m) for "multi-line mode" makes the caret and dollar match at the start and end of each line in the subject string.

(?s) equals Pattern.DOTALL

    沒有留言:

    張貼留言

    Ads

    Seo Services