Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out if two strings are mostly equal (in perl)?

I have a string that I want to compare against an array of strings, and return the array element that most closely matches.

I can write a sliding correlator that counts the number of matching characters at each step and returns the max correlation. But is there a better way?

For example:
control_string = drv_probability_1_max

List:
burst_period_min/max
duty_cycle_min/max
probablility_0_min/max
probablility_1_min/max

Where ideally it returns "probablility_1_min/max"

like image 376
SDGator Avatar asked Dec 21 '22 22:12

SDGator


1 Answers

You might be looking for the String::Similarity module.

like image 115
rafl Avatar answered Apr 04 '23 00:04

rafl