← Back to R Course | Chapter 6: Strings | Lesson 4 of 7

toupper और tolower

toupper हर letter को एक capital में बदलता है और tolower इन्हें small letters में बदलता है, text के लिए एक volume knob की तरह। यह मदद करता है जब आप चाहते हैं words same दिखें।

In this page:

  1. toupper और tolower
Syntax
r
toupper(string)
tolower(string)

toupper और tolower

toupper() एक string को सारी uppercase में convert करता है, और tolower() इसे सारी lowercase में convert करता है। दोनों strings के एक vector पर element-wise काम करते हैं। ये आमतौर पर case-insensitive comparisons के लिए दोनों sides को पहले same case में normalize करके इस्तेमाल होते हैं।

Note: Case-insensitive comparisons के लिए, == से compare करने से पहले tolower() से दोनों strings normalize करें।

उदाहरण: toupper and tolower

markup
text <- "Hello World"

cat(toupper(text), "\n")
cat(tolower(text), "\n")
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. यह उम्मीद करना कि toupper(text) text बदल देगा, जब यह एक नई string return करता है जब तक आप इसे assign न करें।
  2. case match किए बिना strings compare करना, जैसे "Yes" == "yes", जो FALSE है; पहले tolower() से convert करें।
  3. एक number पर toupper इस्तेमाल करना और एक string पाना, जब value character बन जाती है।
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.