Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

new lines between tags

Last post 11-18-2009, 5:51 AM by BubikolRamios. 2 replies.
Sort Posts: Previous Next
  •  11-17-2009, 9:15 PM 57377

    new lines between tags

    source: 

    <B>aaa</B>

    java regex to find this:

    code to convert: <B>aaa</B> to  aaa:

       
        CRLF = Pattern.compile("<b\\b[^>]*>(.*?)</b>",Pattern.CASE_INSENSITIVE);
        m = CRLF.matcher(s);
        while (m.find())
        {
          s1 = m.group(1);//to kar je vmes med bold tagi
          s = s.replaceFirst(m.group(0),"" + s1 + "");
        }

    it stops working when source is in multiline,like: 

     

    <B>a

    a

    a</B>

     

    Thanks for help.

     

  •  11-18-2009, 12:55 AM 57379 in reply to 57377

    Re: new lines between tags

    When you  compile the pattern, add in the "single line" option (also called "dot matches newline" in come places). I don't know the exact name in java.

    Susan

  •  11-18-2009, 5:51 AM 57386 in reply to 57379

    Re: new lines between tags

    Thanks!  

    This is what it looks like in java:

    CRLF = Pattern.compile("<b\\b[^>]*>(.*?)</b>",Pattern.CASE_INSENSITIVE | Pattern.DOTALL);

View as RSS news feed in XML