小编Joh*_*ith的帖子

如何在java中更改正则表达式搜索以忽略大小写

如何更改以下代码,以便它不关心大小写?

public static String tagValue(String inHTML, String tag)
            throws DataNotFoundException {
        String value = null;
        Matcher m = null;

        int count = 0;
        try {

        String searchFor = "<" + tag + ">(.*?)</" + tag + ">";

        Pattern pattern = Pattern.compile(searchFor);

         m = pattern.matcher(inHTML);


            while (m.find()) {
                count++;


                return inHTML.substring(m.start(), m.end());
                // System.out.println(inHTML.substring(m.start(), m.end()));
            }
        } catch (Exception e) {
            throw new DataNotFoundException("Can't Find " + tag + "Tag.");
        }

        if (count == 0) {
            throw new DataNotFoundException("Can't Find " …
Run Code Online (Sandbox Code Playgroud)

java regex

0
推荐指数
1
解决办法
263
查看次数

标签 统计

java ×1

regex ×1