separateMethod method

Tuple2<String, int> separateMethod(
  1. String method
)

Separate the method into the passwordAppend step and the repetition step

Returns a Tuple2 with item1 being the passwordAppend and item2 being the repetition count.

Implementation

Tuple2<String, int> separateMethod(String method) {
  final pattern = RegExp(r'([a-zA-Z]+)(\d+)');
  final match = pattern.firstMatch(method);

  if (match == null) {
    throw FormatException('Invalid input format: $method');
  }

  final passwordAppend = match.group(1)!;
  final repetitions = int.parse(match.group(2)!);

  return Tuple2(passwordAppend, repetitions);
}