1
00:00:01,660 --> 00:00:08,350
String comparison in beshe can be from the beginning found as difficult because it has many rules such

2
00:00:08,350 --> 00:00:12,530
as when to score marks and to double brackets.

3
00:00:12,580 --> 00:00:16,190
In addition some scripts using double square brackets are not.

4
00:00:16,360 --> 00:00:23,310
So generally when you don't know what is going on here you may feel kind of lost but I need to tell

5
00:00:23,310 --> 00:00:28,200
you that string comparison is quite easy when you know the rules.

6
00:00:28,210 --> 00:00:34,000
In fact I believe that by end of this lecture you say OK it's quite simple.

7
00:00:34,060 --> 00:00:37,590
So let's look how to compare two strings.

8
00:00:39,420 --> 00:00:44,850
For string comparison we are using single square brackets and inside it.

9
00:00:44,880 --> 00:00:50,370
Dollar sign for is the variable equal sign or sign second variable.

10
00:00:50,370 --> 00:00:56,160
Those two variables are inside double quotation marks.

11
00:00:56,160 --> 00:01:00,590
Similarly you can compare a variable with some string.

12
00:01:00,900 --> 00:01:09,500
In our case which string how it is really important to not forget on spaces Otherwise you will have

13
00:01:09,510 --> 00:01:12,020
problem running that comparison.

14
00:01:12,120 --> 00:01:19,290
It may feel strange to put spaces next to brackets and variables especially if you know some other programming

15
00:01:19,290 --> 00:01:26,370
language where a condition of writing is not space sensitive but by creating scripts and practicing

16
00:01:26,430 --> 00:01:29,910
you quickly get used to it.

17
00:01:30,030 --> 00:01:38,310
We said that for string comparison we are using a variable name inside double quotation mark why we

18
00:01:38,310 --> 00:01:46,920
do that because if you don't do that and some string is not defined or empty you get an error message

19
00:01:47,340 --> 00:01:52,290
which would lead to not properly working script.

20
00:01:52,750 --> 00:01:59,020
But in beshe there is a way how to not use double quotation marks.

21
00:01:59,020 --> 00:02:02,940
It is by using double square brackets.

22
00:02:03,030 --> 00:02:10,540
And should be mention that this is not vitally whilst most people are using single square brackets and

23
00:02:10,540 --> 00:02:18,070
double quotation marks around variables but the board ways are correct and it is up to you would you

24
00:02:18,070 --> 00:02:19,580
prefer.

25
00:02:19,580 --> 00:02:28,300
Also if you use double square brackets you can also use quotation marks around the variables.

26
00:02:28,300 --> 00:02:30,250
There is no issue with that.

27
00:02:30,450 --> 00:02:36,290
Only you would get slightly larger called.

28
00:02:36,560 --> 00:02:47,750
We can also test if a string is empty by using dataset or an open and when using Desch is that it is

29
00:02:47,750 --> 00:02:51,650
written through if string is empty.

30
00:02:51,650 --> 00:02:58,970
When we use Desch M it is written through in a case that string is not empty.

31
00:02:59,750 --> 00:03:08,850
And of course as for comparing two strings we can use double square brackets instead of single and in

32
00:03:08,850 --> 00:03:15,000
such case we don't need to have double quotation marks around variables.

33
00:03:15,000 --> 00:03:18,040
It is again up to you what do you prefer.

34
00:03:18,450 --> 00:03:27,830
Mostly it is use single square to break it with the double quotation marks around var..

35
00:03:27,850 --> 00:03:34,300
We can also alphabetically compare two strings if you want to compare alphabetically.

36
00:03:34,480 --> 00:03:37,100
We need to use doubles square brackets.

37
00:03:37,240 --> 00:03:41,460
You don't have a choice between double and single square brackets.

38
00:03:43,530 --> 00:03:51,900
For string comparison we are also using a wildcard in regular expressions but those two techniques are

39
00:03:51,900 --> 00:03:52,980
quite complex.

40
00:03:52,980 --> 00:03:58,050
So I will tell you more about them in separate lecture.

41
00:03:58,090 --> 00:04:04,810
Now we see that for string comparison there are some rules which might seem complicated.

42
00:04:05,110 --> 00:04:08,170
The best way how to remember them is to practice.

43
00:04:08,290 --> 00:04:11,480
So let's write some script to see it in action.
