From the course: Perl 5 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Splitting strings - Perl Tutorial
From the course: Perl 5 Essential Training
Splitting strings
- [Voiceover] The split function is used to split a string into an array of parts, using regular expressions, and if I go ahead and run this, you'll see that it splits this string up into an array, and displays each of the words separately from the array, and so split takes a regular expression as its first argument, and then the string as its second argument, and it returns a list which can be used to initialize an array or I could even just take that and put it right at the, in the for each, and run it, and we get exactly the same result. Where this comes in handy is things like, for example an IP address, if I have 192.0.5.127, and I wanna split on the period, now the period of course is a wildcard character, so if I wanna use a literal period I have to put a backslash before it, and I run that, and now I have the parts of my IP address, all in separate convenient strings in a list, or for example, let's say I had a string that had a bunch of different values separated by colons…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
(Locked)
About regular expressions4m 8s
-
(Locked)
Matching text2m 9s
-
(Locked)
Common modifiers4m 58s
-
(Locked)
Extracting matches2m 5s
-
(Locked)
Getting a list of matches1m 46s
-
(Locked)
Simple matches2m 46s
-
(Locked)
Matching wildcards4m 38s
-
(Locked)
Matching classes of characters4m 23s
-
(Locked)
Matching metacharacters1m 37s
-
(Locked)
Search and replace4m 32s
-
(Locked)
Splitting strings2m 18s
-
(Locked)
-
-
-
-
-
-
-