0

I have two variables

String firstInput = "1.1.5";
String secondInput = "1.1.6";

From this I want the output firstOutput = 115 secondOutput = 116 How to remove dots from the string and concatenate remains as one variable ?

Bawantha
  • 2,605
  • 3
  • 19
  • 25

2 Answers2

2

You can use the replaceAll method.
It would look like String out = firstInput.replaceAll(".","");

Tom Rivoire
  • 439
  • 1
  • 5
0

You can also use replaceAllwith RE as shown below

void main(){
  final myString = '1.3.4.6.6';
  String withoutDots = myString.replaceAll(RegExp('\\.'), ''); "Here \\ is used to as esc char"
  print(withoutDots); // prints 13466

}
Nikhil Badyal
  • 1,399
  • 1
  • 6
  • 18