Skip to content
Advertisement

How to check if strings are similar

I have the following strings

JavaScript

First one under text is input string and the second is the one against which it is matched. Last is their fuzzywuzzy ratio. I’m matching it like this:

JavaScript

If the country name is different it should return a lower score as opposed to when it is similar. Is there any way to do this?

Advertisement

Answer

According to the code you’ve provided, the text to compare seems to have a pattern of

country_name + "guidances/regulations"

You can get the country name by spilt() method

JavaScript

then compare only the Country name

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement