All language subtitles for 121 Working With Strings - Part 2.en_US

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Let's continue with some simple string methods.

And the first two are gonna be

for changing the case of a string.

So that's airline.to lowercase.

And this doesn't require any arguments at all.

And then we also have to uppercase.

And these we use all the time,

as you will see soon in a more real world example.

And here you see that indeed, they transform to string,

all to lowercase, and to uppercase.

And again, you can of course, call these directly,

also on a string, so like this, all right?

But now let's use this on a more practical example,

to fix the capitalization in a passenger name.

capitalization in name, okay?

So let's say that the passenger when he checked in

I misspelled his name, and so it looks like this now.

And so this needs to be fixed,

it should look like this, okay?

So in order to fix it, the first step is usually

to put everything into lowercase here.

So const, passenger, lower

is passenger.to lowercase, like this.

Okay, so basically, we already have now this part here.

And now all we need to do is to essentially

take the first letter, and then the rest of the string

and put these two parts back together.

So passenger, correct, will be passenger lowercase.

And here, we only need the first letter.

So how do we do that,

we take the first letter by using the index zero.

And so this one, we now convert to uppercase, all right?

And now we simply need to add the rest of the string.

So, again, we take passenger lower,

and then we use the slice that we learned

in the last lecture, and start at position number one,

because remember, that will then go to index one,

and take everything until the end of the string.

And so here, we then put back together,

just the first part of the string

converted to uppercase here, and then the rest of the string

that we already had converted to lowercase before.

Now, okay, and, indeed, now it is corrected, great.

And of course, we could have done a function with this.

And so maybe if you have the time, you can do that.

So just create a function which takes any passenger name,

and then returns the correct one.

So with the fixed capitalization, but anyway,

I will now do another real life example,

which is to check a user input email, okay?

So check email, now, this will not be really a checking,

it will more be a comparing, so comparing emails.

So let's say that we have to email of one passenger.

So hello at Jonas.io, but now as the user logs in,

so let's say login email, accidentally they do it all wrong,

and they start with a couple of spaces here,

and then the capitalization is all completely off

like this, and then maybe even another space,

or even an enter character, which remember is backslash n.

So I think we talked about that in the beginning, okay?

But still, this email here is actually still kind of correct

and kind of valid.

And so we can now still compare

if these two are kind of the same, okay?

So we can now try to convert this one to this one,

and then check if they are the same.

Because essentially, again, they are,

they would be different if we had

like different letters here, then of course,

they would not be the same.

But here it's just a matter of capitalization.

And for emails I believe that they are still valid

even with the capitalization off.

And so when we check user input like this,

the first step is usually to convert it to lowercase.

So lower email, is login email.to lowercase.

And then we must also get rid of all the whitespace here.

So these empty spaces, and also this enter basically here

also counts as a whitespace.

So there is even a method for that.

So let's say, trimmed email.

And so that is lower email.trim.

All right, let's just now log this to the console

just to see.

And so that looks exactly like that first version.

Now, just look closely at what we did here.

So we called to lowercase on this login email,

stored it to this variable,

and then on that variable, we called the trim method.

But why do we even need this intermediate email?

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.