- Remove square brackets from string in java.
 - We can remove square brackets from string by using regular expressions.
 - By using regular expressions we can remove any special characters from string.
 - Now , we will check how to remove brackets from a string using regular expressions in java.
 
#1: Java Example program to remove brackets from string using regex.
- package com.instanceofjava;
 - /**
 - * @author www.Instanceofjava.com
 - * @category interview programming questions
 - *
 - * Description: remove square brackets from string
 - *
 - */
 - public class ArrayToString {
 - public static void main(String[] args) {
 - String strbrackets = "[String nundi ][brackets][remove cheyyadam][yela?]";
 - strbrackets = strbrackets.replaceAll("\\[", "").replaceAll("\\]","");
 - System.out.println(strbrackets);
 - }
 - }
 
Output:
- String nundi bracketsremove cheyyadamyela?
 
#2: Java program to remove curly brackets from string 

telugu na meeru
ReplyDelete