MURALI KRISHNAN MT
MURALI KRISHNAN MT

Reputation: 195

How to remove a character from string and concatinate it in Dart | Flutter

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 ?

Upvotes: 1

Views: 6937

Answers (2)

Nikhil Badyal
Nikhil Badyal

Reputation: 1697

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

}

Upvotes: 0

Tom Rivoire
Tom Rivoire

Reputation: 651

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

Upvotes: 3

Related Questions