1

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
  • 3,644
  • 4
  • 24
  • 36

2 Answers2

3

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

Tom Rivoire
  • 627
  • 5
  • 6
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,589
  • 1
  • 9
  • 20