RCIX
RCIX

Reputation: 39457

Haxe -- compare two strings ignoring case?

I'm working on a string-to-bool parsing function for Haxe (somehow the devs got by until now without one >.<) and i figured the best way to check the string would be ignoring case. I'm not sure how to do that though, can someone help me?

Upvotes: 2

Views: 1924

Answers (2)

TroyWorks
TroyWorks

Reputation: 411

Just incase anybody needs copy and paste.

function StringToBool(a:Dynamic):Bool{
 var res:Bool = (cast (a, String).toLowerCase() == "true")?true:false;
return res;
}

Upvotes: -2

Franco Ponticelli
Franco Ponticelli

Reputation: 4430

In std there is not such a function but you can easily add your own:

public static function equalsCI(a : String, b : String) return a.toLowerCase() == b.toLowerCase();

Upvotes: 4

Related Questions