
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
String Lower Function in Lua Programming
There are certain scenarios in our code that when we are working with the strings, we might want some string to be in lowercase, like consider a very basic case of an API which is using an authentication service, and the password for that authentication service should in lowercase, and in that case, we need to convert whatever the password the user enters into lowercase.
Converting a string to its lowercase in Lua is done by the string.lower() function.
Syntax
string.lower(s)
In the above syntax, the identifier s denotes the string which we are trying to convert into its lowercase.
Example
Let’s consider a very simple example of the same, where we will convert a string literal into its lowercase.
Consider the example shown below −
s = string.lower("ABC") print(s)
Output
abc
An important point to note about the string.lower() function is that it doesn’t modify the original string, it just does the modification to a copy of it and returns that copy. Let’s explore this particular case with the help of an example.
Example
Consider the example shown below −
s = "ABC" s1 = string.lower("ABC") print(s) print(s1)
Output
ABC abc
Also, if a string is already in its lowercase form then nothing will change.
Example
Consider the example shown below −
s = "a" string.lower("a") print(s)
Output
a