This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import textwrap | |
stext = input("Enter your text: ") | |
dedented = textwrap.dedent(stext).strip() | |
cwidth = input("Enter your column width: ") | |
try: | |
cwidth = int(cwidth) | |
except: | |
print("Invalid width") | |
exit() | |
print(textwrap.fill(dedented, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
tex = input("Enter your text: ") | |
patt = input("Enter what you would like to match it to: ") | |
match = re.search(patt, tex) | |
if match == None: | |
print("No Match") | |
else: | |
start = int(match.start()) + 1 | |
end = int(match.end()) + 1 | |
if start == end: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Drag this file to your preferred directory" | |
print("Press ENTER") | |
gets | |
list = `ls`.split | |
puts "Files and Folders" | |
puts "-----------------" | |
puts "\n" | |
list.each {|x| puts x} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = input("Enter your text: ") | |
pattern = input("Enter your pattern: ") | |
for match in re.finditer(pattern, text): | |
s = match.start() | |
e = match.end() | |
print("Found: ", pattern, "at:", s, "-", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
text = input("Enter your text: ") | |
pattern = input("Enter your pattern: ") | |
for match in re.finditer(pattern, text): | |
s = match.start() | |
e = match.end() | |
print("Found: ", pattern, "at:", s, "-", e) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import difflib | |
import os | |
text1 = input("Enter text: \n") | |
os.system('clear') | |
text2 = input("Enter a second text: \n") | |
os.system('clear') | |
print("Differences Below:") | |
print("------------------") | |
text1 = text1.splitlines() | |
text2 = text2.splitlines() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from difflib import unified_diff | |
from os import system | |
system('clear') | |
text1 = input("Enter your text: ") | |
text2 = input("Enter a second text: ") | |
text1 = text1.splitlines() | |
text2 = text2.splitlines() | |
diff = unified_diff(text1, text2, lineterm='') | |
print('\n'.join(diff)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
fORt = input("Would you like to open a file or enter your own text?(file/text)\\ | |
n") | |
if fORt == 'text': | |
import collections | |
buffer = '' | |
print("Enter in your text below") | |
while True: | |
line = input() | |
if not line: break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while true | |
print(">>> ") | |
command = gets | |
`#{command}` | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Matcher | |
include Enumerable | |
def initialize(string, match) | |
@string = string | |
@match = match | |
end | |
def each | |
@string.scan(/[#@match]/) do |pattern| | |
yield pattern |