String comparison: Difference between revisions

Content added Content deleted
Line 17: Line 17:
=={{header|AWK}}==
=={{header|AWK}}==


In awk, the string matching operators are case sensitive, and the behaviour of the comparative operators depends on the locale being used. Be very careful with numeric strings, because whether they will be treated as numeric values or strings depends on how the values were obtained, and on which awk interpreter is being used. Numeric strings obtained from the input source, will be treated as numeric values, when compared with other strings containing numeric values. Strings valued defined as constants using singlequote or doublequote enclosures will be treated as strings of characters and compared lexically. The behaviour of the operators when one value is considered to be numeric (eg from the input source), but the other value has been defined explicitly as a numeric string by using singlequote or doublequote enclosures may also vary depending on which awk interpreter is being used.
In awk, the string matching operators are case sensitive, and the behaviour of the comparative operators depends on the locale being used. Be very careful with numeric strings, because whether they will be treated as numeric values or strings depends on how the values were obtained, and on which awk interpreter is being used. Numeric strings obtained from the input source, will be treated as numeric values, when compared with other strings containing numeric values. Strings valued defined as constants using doublequote enclosures will be treated as strings of characters and compared lexically. The behaviour of the operators when one value is considered to be numeric (eg from the input source), but the other value has been defined explicitly as a numeric string by using doublequote enclosures may also vary depending on which awk interpreter is being used.


<lang awk>BEGIN {
<lang awk>BEGIN {