Tcl Regular Expression Cheat Sheet



tcl/python text handling

Regex for Numbers and Number Range. In this article you will learn how to match numbers and number range in Regular expressions. The Regex number range include matching 0 to 9, 1 to 9, 0 to 10, 1 to 10, 1 to 12, 1 to 16 and 1-31, 1-32, 0-99, 0-100, 1-100,1-127, 0-255, 0-999, 1-999, 1-1000 and 1-9999. 🍻 awesome cheatsheet. A regular expression (shortened as regex or regexp; also referred to as rational expression) is a sequence of characters that specifies a search pattern.Usually such patterns are used by string-searching algorithms for 'find' or 'find and replace' operations on strings, or for input validation.

These are examples of text filtering in both TCL and Python. This is my first foray into scripting with both TCL and Python, which affords me the opportunity to hurt my brain trying to recall the differences in style and form of both languages.

string match function

I implemented text handling in two different ways in both TCL and Python. The first example is by using a string match function.

tcl string match

foreach item $rawtext {
if {[string match -nocase *u* $item] 1} {
puts [string trim $item 'tn,./!@#$^*()']
}
}

Wireless computer keyboards for sale. Near Field Communication. Near Field Communication. Scrolling Wheel. Scrolling Wheel. Integrated Keyboard. Integrated Keyboard. Logitech K400 Plus Touchpad Wireless Keyboard Black - USB Wireless Connectivity - On/Off Power Switch - 2.40 GHz Operating Frequency. Logitech MK550 Wireless Wave Keyboard and Mouse: Enjoy freedom of motion while working at your PC with this keyboard and mouse that wirelessly connect to your computer from up to 33 feet away. Logitech - G915 TKL Tenkeyless LIGHTSPEED Wireless TKL RGB Mechanical Gaming GL Tactile Switch Keyboard with Back Lighting - Black Model: 920-009495 SKU: 6414194.

python string match

Tcl Regular Expression Cheat Sheet Download

Tcl regular expression cheat sheet downloadTcl regular expression cheat sheet download

for word in text[:]:
if word.find('u') != -1:
print word.strip('tn,./!@#$^*()')

Tcl Regular Expression Cheat SheetTcl Regular Expression Cheat Sheet

regex implementation

Next, I used a regular expression to accomplish the same task. Regular Expressions (regex) can be efficient for pattern matching and interpreting complex lists.

Tcl Regular Expression Cheat Sheet 2019

tcl regex

foreach item $rawtext {
if {[regexp {u|U+} $item] 1} {
puts [string trim $item 'tn,./!@#$^*()']
}
}

python regex

Regular expression tcl

Firefox for mac high sierra. for word in text[:]:
containU = 'u|U+'
if re.search(containU, word):
print word.strip('tn,./!@#$^*()')

The regular expression I used above is really simple, but these can be chained together to test for an incredible range in patterns. Here's a cheat sheet. (png, 84kb)