הלינקייה: מגזין חודשי למפתחים
רוצה לשמוע על כל האירועים, המדריכים, הקורסים והמאמרים שנכתבו החודש ?
הלינקייה הינו מגזין חופשי בעברית שמשאיר אותך בעניינים.
בלי ספאם. בלי שטויות. פעם בחודש אצלך בתיבה.
Regular Expressions Exercise
Write a program that prints only input lines that match the template:
- Write a regular expression to accept any binary string (only 0s and 1s)
- A binary string represents an even number if it ends with a 0. Write a regular expression to match an even number represented as a binary string.
- All lines from ls -l which represent a folder
- Lines longer than 50 characters
- Lines that have even length
Write a program that takes a file with UNIX path names and translate it into windows paths (changing the / to \, and adding drive letter).
/etc/passwd /home/bob/bookmarks.xml /home/bob/vimrc
C:\etc\passwd C:\home\bob\bookmarks.xml C:\home\bob\vimrc
Write a perl program that takes a CSV file with 3 fields: first name, last name, email; and swaps the columns, printing the values: last name, first name, email.
A sample input:
Shana,Sargent,email@example.com Witt,Hampton,firstname.lastname@example.org Morgan,Grant,email@example.com
And the output:
Sargent,Shana,firstname.lastname@example.org Hampton,Witt,email@example.com Grant,Morgan,firstname.lastname@example.org
- Write a program to print every other word in a sentence. So for the input "I Love Writing Perl Code", it should print "I Writing Code"
- Write a program that takes lines of inputs and prints "Valid" if the line holds a legal perl variable identifier.
- Write a program to read a file and print lines containing only numbers
- Write a program that extracts words inside a double quoted strings. For instance, taking the input: he said "Goog Morning" and then went away, should produce the output: Good Morning
- Write a program that matches a time-of-day string (such as 9:14 am or 11:20 pm).
- Write a Regular expression to delete duplicate words
- Write a regular expression to match a valid email address.
- Write a regular expression to match a valid IP Address (remember that 0.0.0.0 is valid, but 300.0.0.0 is not)
- Write a regular expression that takes a line and prints only the words that have an odd number of letters
- Write a program that reads all file names in a directory and prints only the really long ones (longer than 20 characters)
- Write a program that reads all file names in a directory, and searches for secrets. If a file's extension is .txt, it should read it and print any line in ithe file with the words TOP SECRET somewhere on the line
- Write a program that calculates frequency of appearnce for words in text. The program should take a file name from the command line, and, for each word in the file, prints how many times it appears in the text.